开发者

Is it possible to subscribe on event when backbonejs view is removed from dom?

Is it possible to subscribe on event when backbonejs view is removed from dom?

开发者_如何转开发

I need to handle this to unsubscribe from websocket connection.


It is possible using Jquery UI. I've described solution in my blog: http://zakharov.posterous.com/how-to-handle-when-backbonejs-view-is-remove


What triggers the removal of the view from the DOM? If the view is managing this removal, whomever created the view or has a reference to the view can register to receive an event that the view can trigger when this DOM removal happens.

I haven't tried it, but you might be able to wire up the DOMNodeRemoved event as an event that the view registers a function for. You would then bubble this DOM event up through your app for any interested listener to respond to.


You can trigger a custom event on the method which is being called to close down the view. Then just have something listening to this event.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜