Is there any way to listen to delete / kill events on a Backbone view.?
I want to do something like below:
$(myBackboneView).on('remove', function () { // do some processing });
or
$(myBackboneView).on('destroy', function () { // do some processing });
Thanks in advance.:)
You can try to override the method View.remove::
View.remove
Backbone.View.extend({ remove: function(){ // Your processing code here Backbone.View.prototype.remove.apply(this, arguments); }; });
I tried the following and this works for me:
$(myBackboneView.el).on('remove', function () { // do some processing });
Is this a good approach? Or is there something even better than this?
, "" remove().
BaseView = Backbone.View.extend({ remove: function () { this.trigger('remove', this) return Backbone.View.prototype.remove.apply(this, arguments) } })
, :
this.listenTo(otherView, 'remove', func)
Source: https://habr.com/ru/post/1523846/More articles:Why is Scala for loops slower than logically identical while loops? - scalaElastic Cloud Search Clustering - elasticsearchSimple java pyramid program - javaC # Unmanaged exports with multiple projects (Robert Giesecke) - c #Sending GL Uniforms: Multiple floats versus vector packaging - shaderУстройства WiFi передают пакеты, когда они только что включены? - smartphoneChi-square test with two samples in R - rCheck System.DateTime in UTC - timezoneHow to pass a connection string to a class library? - c #Should the connection string come from an mvc project or data project? - asp.net-mvcAll Articles