abcdef
5 Dec 2011, 6:46 PM
I have 2 models as follows:
Ext.define('MyApp.model.Book', {
extend: 'Ext.data.Model',
fields: [
...
],
hasMany: {
model: 'MyApp.model.Page', name: 'pages'
}
});
Ext.define('MyApp.model.Page', {
extend: 'Ext.data.Model',
fields: [
...
],
belongsTo: 'MyApp.model.Book'
});
After I load the Book store:
listeners: {
load: function(store, records, success, operation) {
if(success) {
store.each(function(book) {
console.log(book.pages());
});
}
}
}
It throws an error:
TypeError: 'undefined' is not a function (evaluating 'book.pages()')
How do I accomplish the behavior described above with namespaced models?
Please help!
Thanks!
Ext.define('MyApp.model.Book', {
extend: 'Ext.data.Model',
fields: [
...
],
hasMany: {
model: 'MyApp.model.Page', name: 'pages'
}
});
Ext.define('MyApp.model.Page', {
extend: 'Ext.data.Model',
fields: [
...
],
belongsTo: 'MyApp.model.Book'
});
After I load the Book store:
listeners: {
load: function(store, records, success, operation) {
if(success) {
store.each(function(book) {
console.log(book.pages());
});
}
}
}
It throws an error:
TypeError: 'undefined' is not a function (evaluating 'book.pages()')
How do I accomplish the behavior described above with namespaced models?
Please help!
Thanks!