This is for a mobile app targeting the 5.1 version of the iPhone sdk in the simulator with Titanium SDK version 2.1.1 (07/27/12 14:01 0fd84a2).
I am attempting to get Backbone.js 0.9.2 to work with Titanium. I have modified the Backbone.sync function to use the Titanium HTTPClient and the data comes back fine.
It looks like there is an issue when the collection is built in the reset function where it adds models to internal hashes for lookup. My guess is that this is causing a memory issue because Titanium crashes hard without a message when this line is run:
this._byCid[model.cid] = model; if (model.id != null) this._byId[model.id] = model; // this will also cause the haltIs there anyone that has gotten backbone and titanium playing together recently that may have some insight on what is wrong/how to fix this?
Thanks, Robert
3 Answers
Accepted Answer
Code seems to be working fine for me.... don't know what you had the parse method in there for?
// load initial data var tweets = new TweetCollection(); tweets.fetch({ error : function(collection, response) { console.log('error'); }, success : function(collection, response) { console.log('success'); // accessing the collection either way causes a crash // [INFO] Application has exited from Simulator for (var i in tweets.models) { console.log(tweets.models[i].get("user").screen_name + " " + tweets.models[i].get("text")); } //console.log(tweets); } });
can you post a simple example with your sync function?
see this also https://gist.github.com/1081802
I created a simple one view app with the backbone code I have now. I pointed it to a random twitter stream for data, and zipped the whole project.
Thanks for any help figuring out what is wrong.
Your Answer
Think you can help? Login to answer this question!