我试图理解以下代码:
muConfigView.on("mu:field:changed", function() {
updateButtonState();
}, this);
或者
this.trigger('validate:fields');
我已经看到了我理解的变化等事件的例子。
有人可以解释一下"mu:field:changed"
&的目的'validate:fields'
是什么吗?
我试图理解以下代码:
muConfigView.on("mu:field:changed", function() {
updateButtonState();
}, this);
或者
this.trigger('validate:fields');
我已经看到了我理解的变化等事件的例子。
有人可以解释一下"mu:field:changed"
&的目的'validate:fields'
是什么吗?
Backbone has it's own events built in, but you can also make up your own, which you can trigger and listen for.
The convention is to "namespace" events using colons (:
) so that you can better organise your code as it can soon get out of hand once you start using a lot of events.
In your first example, when the mu:field:changed
is triggered, the anonymous function will be called.
In your second example, the validate:fields
event is being fired and will be handled by a listener somewhere else.