WangHongjian
WangHongjian

Reputation: 383

How to avoid triggering change event when new model is added into collection in backbone?

Now I have defined a collection, and bond both add and change event listener, but when a new model is added, the change event will be triggered.

collection.bind('add',addMethod);
collection.bind('change',changeMethod);

How can I avoid triggering change event?

Upvotes: 0

Views: 105

Answers (1)

Tohveli
Tohveli

Reputation: 485

As mentioned in comments, when you add something to your collection, add silent-option to that function-call. Check Backbonejs reference for more info.

collection.add(someModel, {silent: true});

Upvotes: 1

Related Questions