Is there any way to listen to remove/destroy event on the Backbone View.?
I want to do some thing like as below:
$(myBackboneView).on('remove', function () {
// do some processing
});
or
$(myBackboneView).on('destroy', function () {
// do some processing
});
Thank you in advance. :)
You can try to override the View.remove
method::
Backbone.View.extend({
remove: function(){
// Your processing code here
Backbone.View.prototype.remove.apply(this, arguments);
};
});
I tried the following and it works for me:
$(myBackboneView.el).on('remove', function () {
// do some processing
});
Is this is a good approach ? Or there is something else better than this?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With