PDA

View Full Version : [FIXED-114] Creating new instance of Model results in "dirty" object



jeroenvduffelen
28 Jun 2010, 2:24 AM
I've got a simple model here:



Ext.regModel('book', {
idProperty: 'bookId',
fields: [
{name: 'bookId', type: 'string', defaultValue: 'grmbl..'},
{name: 'bookTitle', type: 'string'},
],
});




var objBook = Ext.ModelMgr.create({}, 'book');

When create a new instance of this model without any values i get a clean new object as a result:

21142



var objBook = Ext.ModelMgr.create({
bookId: 'testId',
bookTitle: 'testTitle',
}, 'book');

But when I create a new instance of this model with values i get a dirty object like this:

21141

So it doesn't only add the field values to the data object inside the model but it adds the values to the object itself as well....

xantus
29 Jun 2010, 11:13 AM
Thanks. I created a ticket for this issue.

edspencer
29 Jun 2010, 11:49 AM
Finally tracked this down, it's because Model now inherits from Observable. Fixed the problem in source control so it will make the next release.

jeroenvduffelen
29 Jun 2010, 12:42 PM
Cool, posting another bug. Keeping you guys busy ;-)

edspencer
29 Jun 2010, 12:43 PM
Cool, posting another bug. Keeping you guys busy ;-)

Thanks, we appreciate it :)

jeroenvduffelen
30 Jun 2010, 4:14 PM
Using this code I still get dirty objects with Sencha Touch version 0.91



var store = new Ext.data.JsonStore({
autoLoad: true,
model: 'book',
proxy: {
url: '/books.json',
type: 'ajax',
reader: {
root: 'books',
type: 'json',
},
writer: {
type: 'json',
}
},
storeId: 'books',
});

edspencer
30 Jun 2010, 4:25 PM
Yeah we fixed it but another piece of the code was relying on the bug. I deliberately restored the incorrect behavior you mention until we update the other code to honor the data property correctly.

jeroenvduffelen
30 Jun 2010, 4:26 PM
Cool! Keeping you sharp ;)

gcallaghan
23 Feb 2011, 6:05 PM
Is this fixed?
I am getting models marked as dirty when I load a store with a localstorage proxy.