Backbone.js 0.9.10集合获取JSONP

时间:2013-02-06 04:20:44

标签: backbone.js

var COLLECTION = Backbone.Collection.extend({
    url: "example.com",
    sync: function(method, model, options){
        params = _.extend({
            type: "get",
            url: this.url,
            async: false,
            dataType: "jsonp",
            jsonpCallback : "jsonp_callback",
        },options);

        return $.ajax(params);
    },
    parse:function(response){
        console.log(response);
        return response;
    }
});
var a = new COLLECTION();
var b = new COLLECTION();
$.when(a.fetch(),b.fetch()).done(function(){ console.log('done'); });

我有两个问题:

  1. 在同步功能中,$ .ajax(params)响应TypeError: a["reset"] is not a function @ 0.9.10
  2. 使用多个collection.fetch有时会发生a.fetch() or b.fetch() response parse error
  3. 谢谢!

0 个答案:

没有答案