Nageswaran
Nageswaran

Reputation: 7661

Bind a method after Backbone's fetch event

var BasicModel = Backbone.Model.extends({

   url : function() {
       return "/something";
    }

});

var basicModel = new BasicModel();
basicModel.fetch();

If BasicModel is a collection, then the follwoing is possible

   this.on("add", function (model) {
         console.log(model);
    });

Is there any lisiting event I can bind for Backbone model, which get invoked after fetch happened?

Upvotes: 0

Views: 463

Answers (2)

Ravi Hamsa
Ravi Hamsa

Reputation: 4721

basicModel.fetch({success:function(){
      //do whatever you want
}});

Upvotes: 0

Sathya
Sathya

Reputation: 5308

use change event.

in your model.

this.on("change", function);

or in your view

this.model.on("change", function);

Upvotes: 1

Related Questions