The resize
event is sent to window
:
The resize
event is sent to the window
element when the size of the browser window changes
But a Backbone view's events are bound to the view's el
using delegate
. The view's el
won't get a resize
event so putting 'resize articule': 'repositionBoards'
in your view's events
won't do any good.
If you need to get the resize
event in your view, you'll have to bind it to window
yourself:
initialize: (options) ->
$(window).on('resize', this.repositionBoards)
remove: ->
$(window).off('resize', this.repositionBoards) # Clean up after yourself.
@$el.remove() # The default implementation does this.
@
repositionBoards: ->
# Use => if you need to worry about what `@` is
board.align()
Also note the addition of a remove
so that you can unbind your resize
handler. You will, of course, want to use view.remove()
to remove your view or just don't worry about it if that view is your whole application.