You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 6, 2019. It is now read-only.
William Meleyal edited this page May 30, 2013
·
3 revisions
Backbone.Widget can optionally remove itself on a given event.
This can be useful if you're using pjax / turbolinks and need to routinely cleanup views between "page loads".
Define the uninstall event
Backbone.Widget.removeEvent='page:change'
Default remove()
View.remove() will now automatically be called whenever the removeEvent fires.
Custom remove()
If you define your own remove method, you need to also call "super" so Backbone.Widget can perform it's own cleanup. This will hopefully be fixed in a future release.
JavaScript
MyView=Backbone.Widget.extend({remove: function(){Backbone.Widget.prototype.remove.call(this)// 'super'// your custom cleanup...}})
CoffeeScript
MyViewextendsBackbone.Widgetremove:->super# your custom cleanup...