gpt4 book ai didi

javascript - 钛合金 Backbone 和ACS

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:43:11 25 4
gpt4 key购买 nike

我正在尝试将数据从 Appcelerator 云服务传递到 Backbone 模型。我找不到有关如何执行此操作的文档...

下面是我的模型文件的配置:

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[key];
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;
}
};

如何从 ACS 传递数据?

最佳答案

您需要在配置中使用“acs”。

检查这个:

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[key];
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;
}
};

查看此演示文稿:Titanium presentation在标题为“合金中的 ACS”的 ACS 主题下。

此外,这里是示例:Alloy backbone & ACS

希望这对您有所帮助。

关于javascript - 钛合金 Backbone 和ACS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23569603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com