[ALOY-1162] Backbone 1.1.2 : <model/property> sample returning unexpected data for model attributes
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-10-24T15:29:37.000+0000 |
Affected Version/s | Alloy 1.6.0 |
Fix Version/s | Alloy 1.6.0 |
Components | Models |
Labels | n/a |
Reporter | Federico Casali |
Assignee | Feon Sua Xin Miao |
Created | 2014-10-13T22:42:00.000+0000 |
Updated | 2015-03-30T21:06:30.000+0000 |
Description
Problem description
Using Backbone 1.1.2, sample app included inSteps to reproduce
Currently working on narrowing down the sample code. However it can be reproduced by getting the alloy sample for model/properties (https://github.com/appcelerator/alloy/tree/master/test/apps/models/properties ) 1. Import the sample code 2. Add backbone support in config.json and in the 'exports.definition = {}' add:
{
"sourcemap": false,
"adapters": ["properties"],
"backbone": "1.1.2"
}
3. Edit models/modelTab.js and add
extendCollection : function(Collection) {
_.extend(Collection.prototype, {
// For Backbone v1.1.2, uncomment this to override the fetch method
fetch: function(options) {
options = options ? _.clone(options) : {};
options.reset = true;
return Backbone.Collection.prototype.fetch.call(this, options);
},
comparator: function(singleModel) {
return singleModel.get('done');
}
});
return Collection;
}
4. Run
5. Click on Increment a few times. Then close the app.
Result: label is updated accordingly as expected, incrementing the count. Displayed label is something like:
model: {"id":"instance", "count":2}
6. Reopen the app
Displayed label is now different than expected, returning a new model with count 0 and the previous created/incremented models.
See attachment.
Attachments
File | Date | Size |
---|---|---|
Screen Shot 2014-10-13 at 3.41.19 PM.png | 2014-10-13T22:42:00.000+0000 | 28976 |
PR : https://github.com/appcelerator/alloy/pull/593 Function Test: 1. Run the sample app included in
PR merged
1_6_X: https://github.com/appcelerator/alloy/pull/600
PR merged
Verified fixed using: Titanium SDK 4.0.0.v20150325201813 Studio 4.0.0.201503271912 Appc NPM: 0.3.37 Appc CLI 0.2.204 Alloy 1.6.0-alpha2 Label content and list items are maintained through app closures, as described.