Does the .add spine create when collecting a collection?

I am converting my base application so that it starts communicating with the server, earlier I just filled the collection with test data using .add()

I associated some events with the event of adding collections. Therefore, every time an item is added to the collection, I can visualize the view and update some statistics.

it seems that as soon as I add a call .fetch()to receive data from the server, the add events will stop.

eg

var PayableCommitmentCollection = Backbone.Collection.extend({
    model:PayableCommitment,
    url:"/cc/account/contributions/",

    initialize: function() {
        this.bind("add",this.setInitialAmount,this);
    }
 }

this.SetInitialAmount() never called after fetch creates models in the collection.

I also have 2 views that view items that will be added to this collection that are no longer being updated.

- AJAX, , , , , .

- , , .

+5
2

:

collection.fetch([options])

, , .

reset:

reset collection.reset(models, [options])

- , , . reset, ( ), "reset" .

, fetch "reset", "add". - setInitialAmount, "reset".


Backbone 1.0 Collection#fetch :

collection.fetch([options])

, , .
[...]
set. , , "add" "change" , : collection.fetch({remove: false})

, 1.0+, fetch remove: false.

+5

. "", reset.

collection.fetch({ add: true });
+6

All Articles