Created
August 16, 2013 15:14
-
-
Save lcruz/6250783 to your computer and use it in GitHub Desktop.
Backbone model example in Titanium + Alloy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I bind the Model to a View?