javascript - 钛合金主干和ACS
<p><p>我正在尝试将数据从 Appcelerator 云服务传递到主干模型。我找不到有关如何执行此操作的文档... </p>
<p>以下是我的模型文件中的配置:</p>
<pre><code>exports.definition = {
config: {
"columns": {
"id":"integer",
"address":"text",
"user_completed":"integer"
},
"adapter": {
"type": "", //what can I enter?
"collection_name": "places"
}
},
extendModel : function(Model) {
_.extend(Model.prototype, {
validate : function(attrs) {
for (var key in attrs) {
var value = attrs;
if (value) {
if (key === "item") {
if (value.length <= 0) {
return 'Error: No item!';
}
}
if (key === "done") {
if (value.length <= 0) {
return 'Error: No completed flag!';
}
}
}
}
}
});
return Model;
},
extendCollection : function(Collection) {
_.extend(Collection.prototype, {
comparator: function(places) {
return places.get('done');
}
});
return Collection;
}
};
</code></pre>
<p>如何从 ACS 传递数据?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您需要在配置中使用“<code>acs</code>”。</p>
<p>检查一下:</p>
<pre><code>exports.definition = {
config: {
"columns": {
"id":"integer",
"address":"text",
"user_completed":"integer"
},
"adapter": {
"type": "acs",// Use "acs"
"collection_name": "places"
}
},
extendModel : function(Model) {
_.extend(Model.prototype, {
validate : function(attrs) {
for (var key in attrs) {
var value = attrs;
if (value) {
if (key === "item") {
if (value.length <= 0) {
return 'Error: No item!';
}
}
if (key === "done") {
if (value.length <= 0) {
return 'Error: No completed flag!';
}
}
}
}
}
});
return Model;
},
extendCollection : function(Collection) {
_.extend(Collection.prototype, {
comparator: function(places) {
return places.get('done');
}
});
return Collection;
}
};
</code></pre>
<p>查看此演示文稿:<a href="http://www4.uwm.edu/mobile/class/slides/tcd_training/11acs/index.html#/" rel="noreferrer noopener nofollow">Titanium presentation</a>在带有“<strong>ACS in Alloy</strong>”标题的 ACS 主题下。</p>
<p>另外,这里是示例:<a href="https://github.com/aaronksaunders/ci.alloy.acs.books" rel="noreferrer noopener nofollow">Alloy backbone & ACS</a> </p>
<p>希望这会有所帮助。</p></p>
<p style="font-size: 20px;">关于javascript - 钛合金主干和ACS,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/23569603/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/23569603/
</a>
</p>
页:
[1]