0

尝试添加标签时,我不断收到以下错误: TypeError: Object has no method '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');
                    }
            });
        }
    },

我究竟做错了什么?

4

1 回答 1

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');
                    }
                });
            }}
        });
    }

}, 

});

于 2013-10-31T23:53:23.390 回答