Backbone.js fetch not actually setting attributes

后端 未结 2 1780
不思量自难忘°
不思量自难忘° 2020-11-29 10:07

I have a basic backbone model, its urlRoot attribute is set and the corresponding target on the server side returns a correct JSON output (both JSON string and

2条回答
  •  离开以前
    2020-11-29 10:15

    Just as a quick remark when using events in this example. It did not work with change in my case because this events fire on every change. So sync does the trick.

    var athlete = new Athlete({id: 1});
    athlete.on("sync", function (model) {
       console.log(model.get('name'));
    });
    athlete.fetch();
    

提交回复
热议问题