javascript - Is there a way to listen silent events on backbonejs? -
i'm trying listen backbone's model's ´changed´-event attribute, like
this.listento(this, 'change:someattr', this.eventlistener);
however, changed silently, normal event listening not work. there way listen backbone's silent events?
the way can think of via sort of "polling", ie checking on , on via setinterval.
initialize: function() { this.listensilent(); }, listensilent: function() { var startval = this.get('myattr'); var = this; var silentlistener = setinterval(function() { if (that.get('myattr') !== startval) { that.trigger('myevent'); // custom event name can listen stopinterval(silentlistener); that.listensilent(); } }, 100); }
Comments
Post a Comment