Skip to content

Instantly share code, notes, and snippets.

@lcruz
Created August 16, 2013 15:14
Show Gist options
  • Save lcruz/6250783 to your computer and use it in GitHub Desktop.
Save lcruz/6250783 to your computer and use it in GitHub Desktop.
Backbone model example in Titanium + Alloy
var collection = Alloy.createCollection("localnote");
collection.fetch({
success : function(){
_.each(collection.models, function(element, index, list){
Ti.API.info(element.get("title"));
});
},
error : function(){
Ti.API.error("hmm - this is not good!");
}
});
exports.definition = {
config: {
"columns": {
"file": "TEXT",
"title": "TEXT",
"memo": "TEXT",
"note_id": "INTEGER PRIMARY KEY AUTOINCREMENT"
},
"adapter": {
"type": "sql",
"collection_name": "notes",
"idAttribute": "note_id"
}
},
extendModel: function(Model) {
_.extend(Model.prototype, {
});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {});
return Collection;
}
}
@odahcam
Copy link

odahcam commented May 17, 2017

How can I bind the Model to a View?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment