2013-02-22 51 views
0
exports.definition = { 

    config : { 
     // table schema and adapter information 
    }, 

    extendModel: function(Model) {  
     _.extend(Model.prototype, { 
      // Extend, override or implement the Backbone.Model methods      
     }); 
     return Model; 
    }, 

    extendCollection: function(Collection) {   
     _.extend(Collection.prototype, { 

     }); // end extend 

     return Collection; 
    } 
} 

當我嘗試做var model = Alloy.createCollection('model');collection.fetch()不會產生拒絕回答,

alert(appointments.fetch()); 

我沒有得到任何結果。

+0

fetch是異步的。您可以使用'appointments.fetch({success:function(model,response,options){console.log(model,response);}})' – anhulife 2013-02-25 09:49:18

回答

0

fetch是異步的。由於這樣,它會返回一個承諾,或者你需要設置一個回調:

appointments.fetch().done(function(r) { console.log(r) }); 

另外,不要使用alert調試;這是無用的。總是打開您的控制檯並使用console.log

+0

它說不能調用undefined來完成。 – theJava 2013-02-22 15:51:16

+0

是'約會'Backbone集合或模型的實例嗎? (例如:'console.log(約會instanceOf Backbone.Model)') – 2013-02-22 16:10:31

+0

集合的實例 – theJava 2013-02-22 16:14:48