使用AppSDK 2.0rc1将标记添加到标记集合时出错

时间:2013-10-31 23:47:01

标签: tags rally

尝试添加标记时出现以下错误: TypeError:对象没有方法'getModel'

这是我的代码片段:

_onRecordRead: function(record, operation) {
        if(operation.wasSuccessful()) {
            var tagStore = record.getCollection('Tags');
            defectStore.add({'_ref':'/tag/1234'});
            defectStore.sync({
                    callback: function() {
                        console.log('success');
                    }
            });
        }
    },

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您可以先将附加配置传递给getCollection方法来加载商店,加载后可以添加并同步:

Ext.define('CustomApp',{     extend:'Rally.app.App',     componentCls:'app',

launch: function() {
    console.log("launch");
   Rally.data.ModelFactory.getModel({
        type: 'User Story',
        success: this._onModelRetrieved,
        scope: this
    });
},
_onModelRetrieved: function(model) {
    console.log("_onModelRetrieved");
    this.model = model;
    this._readRecord(model);
},

 _readRecord: function(model) {
    var id = 13888228557;
    console.log("_readRecord");
    this.model.load(id, {
        fetch: ['Name', 'Tags'],
        callback: this._onRecordRead,
        scope: this
    });
},

_onRecordRead: function(record, operation) {
    if(operation.wasSuccessful()) {
         var tagStore = record.getCollection('Tags', {
            autoLoad: true,
            listeners: { load: function() {
                tagStore.add({'_ref':'/tag/14749564725'}, {'_ref':'/tag/14749393316'});
                tagStore.sync({
                    callback: function() {
                        console.log('success');
                    }
                });
            }}
        });
    }

}, 

});