尝试添加标记时出现以下错误: 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');
}
});
}
},
我做错了什么?
答案 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');
}
});
}}
});
}
},
});