javascript - 钛合金主干及ACS

标签 javascript android ios backbone.js titanium-alloy

我正在尝试将数据从 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 - 钛合金主干及ACS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23569603/

相关文章:

javascript - Angularfire2 oauth 登录中的凭据无效错误

android - 避免在 Spinner 中显示选定的文本

objective-c - 将 UISearchBar 锁定到 TableView 的顶部

javascript - 删除多行文本区域文本每行上 "-"之前的所有字符

javascript - Redux saga 永远不会运行

javascript - 元素边框上的html鼠标悬停事件

java - 生成两个相同的随机数和一个不同的随机数

java - 如何关闭 Android MediaPlayer 对 null 监听器的投诉

iOS自定义用户界面

ios - 安装 Facebook 应用程序时身份验证失败 (iOS)