3
我得到的錯誤:關聯模型
Uncaught TypeError: Cannot call method 'indexOf' of undefined
Ext.apply.urlAppend ext-all-debug.js:5040
Ext.define.buildUrl ext-all-debug.js:26324
Ext.define.buildRequest ext-all-debug.js:26148
Ext.define.doRequest ext-all-debug.js:26367
Ext.define.read ext-all-debug.js:26117
Ext.define.inheritableStatics.load ext-all-debug.js:26603
(anonymous function) ext-all-debug.js:51162
(anonymous function) test.html:89
isEvent ext-all-debug.js:10117
call ext-all-debug.js:10073
我不知道什麼是煩惱。我檢查了FF中的實例結構,它確實具有函數getCategory。 謝謝!
Ext.define("Category", {
extend: "Ext.data.Model",
fields: ["id", "name"]
});
Ext.define("Product", {
extend: "Ext.data.Model",
fields: ["id", "name", "category_id"],
associations: [{
type: "belongsTo",
model: "Category",
primaryKey: "id",
foreignKey: "category_id",
associationKey: "category"
}]
});
Ext.onReady(function(){
var p = new Product({
id: 1,
name: "Kotomi",
category_id: 2,
category: {
id: 2,
name: "Clannad"
}
});
console.log(p.getCategory().get("name"));
});