How do I fetch a single model in Backbone?

前端 未结 7 1121
误落风尘
误落风尘 2020-11-30 18:36

I have a Clock model in Backbone:

var Clock = Backbone.Model.extend({});

I\'m trying to get an instance of that that has the l

7条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 19:07

    var Person = Backbone.Model.extend({urlRoot : '/person/details'});
    var myName = new Person({id: "12345"});
    myName.fetch();
    

    As a result you make a Ajax request on the

    URL http://[domainName]/person/details/id 
    

    and you have the JSON response back.

    Enjoiiii !!!

提交回复
热议问题