javascript - backbone.js: Prevent listener event from firing when model changes -
i have following listener in view when model changed:
this.listento(this.model, 'change', this.render);
when change model :
model.set('foo', bar);
is possible make not trigger listener event specific function call? still want event trigger @ other calls.
from fine manual:
generally speaking, when calling function emits event (
model.set
,collection.add
, , on...), if you'd prevent event being triggered, may pass{silent: true}
option. note rarely, perhaps never, idea. passing through specific flag in options event callback at, , choose ignore, work out better.
so if don't want specific set
call trigger change event then:
model.set('foo', bar, { silent: true });
or tunnel information render
using custom option:
model.set('foot', bar, { ignore_this: true });
and adjust render
:
render: function(options) { if(options && options.ignore_this) return; // ... }
Comments
Post a Comment