2013-02-05 48 views
1
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, { 

      // Implement the comparator method. 
      comparator : function(book) { 
       return book.get('title'); 
      } 

     }); // end extend 

     return Collection; 
    } 
} 

我應該在哪裏指定url屬性以與我的休息服務進行通信。指定URL或URLRoot屬性 - backbone.js

http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Models

回答

3
exports.definition = { 
    config: { 
      "columns": { 
       "username": "", 
       "password": "" 
      }, 
      "defaults": { 
       "username": "-", 
       "password": "-" 
      }, 
      "adapter": { 
       "type": "restapi", 
       "collection_name": "user" 
      } 
     }, 

    extendModel: function(Model) {  
     _.extend(Model.prototype, { 
      **urlRoot**:'', 
      checkLogin: function(){ 

      } 
     }); 

     return Model; 
    }, 

    extendCollection: function(Collection) {   
     _.extend(Collection.prototype, { 
      // Extend, override or implement Backbone.Collection 
     }); 

     return Collection; 
    } 
} 

Backbone.sync方法執行的RESTful JSON請求由Model.urlRoot或Collection.url屬性指定的URL,創建這些類時。您可以在Model or Collection中指定。

0

我真的不知道Appcelerator的,但在骨幹網添加URL配置在收集,檢查here

0

嗯,我不知道怎麼做,在Appcelerator的骨幹,但只解決方案您需要將URL選項傳遞給您的模型或集合。

首先,您需要創建您的骨幹模型定義url(urlRoot for collection),然後將它們擴展到您的Appcelerator模型中。

下面是來自鈦文件的解釋。

「既然骨幹的主要用途是用於Web應用程序,默認情況下, Backbone.sync方法執行的RESTful JSON請求URL指定 由Model.urlRoot或Collection.url屬性,當這些類 是創建「。

相關問題