Backbone.js Binding to collection “add” renders view twice

Asked By: Anonymous

I am trying to trace all of the zombies in my application and get better understanding of how the event binding happens.
I have a view that binds its collection "add" event to its render function.

_.bindAll(this, "render");
this.collection.bind("add", this.render);

So if I log something in my render function I can see in console that rendering happened twice right after user adds new model through UI. The console output looks like this:

rendering                                  index.js?body=1 (line 88)

POST http://localhost:3000/tasks           jquery.js?body=1 (line 8103)

rendering                                  index.js?body=1 (line 88)

I wonder why is this happening. I know for a fact that model was added only once to the collection so that makes me think that event should only be fired once. Then I don’t understand why render was executed twice.
I have looked in similar question here but it is different because I am using add event instead of change.


Solution

Answered By: Anonymous

It turned out that there was an additional binding to render through Event Aggregator. It was added by another developer.

techinplanet staff

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno