Titanium

[ALOY-1162] Backbone 1.1.2 : <model/property> sample returning unexpected data for model attributes

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-10-24T15:29:37.000+0000
Affected Version/sAlloy 1.6.0
Fix Version/sAlloy 1.6.0
ComponentsModels
Labelsn/a
ReporterFederico Casali
AssigneeFeon Sua Xin Miao
Created2014-10-13T22:42:00.000+0000
Updated2015-03-30T21:06:30.000+0000

Description

Problem description

Using Backbone 1.1.2, sample app included in returns unexpected data values when fetching for stored persistent Model data (using properties adapter).

Steps 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

FileDateSize
Screen Shot 2014-10-13 at 3.41.19 PM.png2014-10-13T22:42:00.000+000028976

Comments

  1. Feon Sua Xin Miao 2014-10-20 PR : https://github.com/appcelerator/alloy/pull/593 Function Test: 1. Run the sample app included in on Backbone 1.1.2 2. Follow the steps to reproduce listed above, the content of the label content should be the same before and after reopen.
  2. Tim Poulsen 2014-10-21 PR merged
  3. Feon Sua Xin Miao 2014-10-24 1_6_X: https://github.com/appcelerator/alloy/pull/600
  4. Tim Poulsen 2014-10-24 PR merged
  5. Eric Wieber 2015-03-30 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.

JSON Source