我有模特
Ext.define('app.model.MyM', {
extend: 'Ext.data.Model',
fields: [
{name: 'test'}
]
proxy: {
type: 'rest',
url: 'getdataHere'
}
});
将数据加载到控制器中的模型中后。
var m = this.getModel('MyM');
m.load(pId, {callback: function(){//do something}});
后来我试图再次加载模型数据,但无法成功,
Ext.ModelManager.getModel('MyM').getData() - an error - constructor.... does not have method getdata
this.getModel('MyM').getData() - the same error
任何想法为什么?我如何获得模型数据?
这是一个错误
Uncaught TypeError: Object function constructor() {
// Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to
// be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.
return this.constructor.apply(this, arguments) || null;
} has no method 'getData'
答案 0 :(得分:0)
您将在回调中获得对模型的引用:
Ext.define('MyController', {
extend: 'Ext.app.Controller',
init: function() {
app.model.MyM.load(id, {
scope: this,
success: this.captureModel
});
this.control({
button: {
click: this.onFooClick
}
});
},
captureModel: function(rec) {
this.rec = rec;
},
onFooClick: function() {
console.log(this.rec);
}
});