-
-
Save jbalthis/9221608 to your computer and use it in GitHub Desktop.
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
// create model factory, pass in Alloy global object | |
var MODELS = new (require('models').MODELS)(Alloy); | |
var person = new MODELS.Person({ | |
"name" : "Reina Saunders", | |
"age" : 2 | |
}); | |
person.save(null, { | |
"success" : function(_m, _r) { | |
Ti.API.info('person ' + JSON.stringify(_m.attributes)); | |
}, | |
"error" : function(_m, _r) { | |
Ti.API.error('person ' + JSON.stringify(_m)); | |
} | |
}); |
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.MODELS = MODELS = function(_Alloy) { debugger; | |
// this accounts for requires implementation and global | |
// Alloy object and the underscore library | |
var A = ( typeof Alloy === "undefined" ? _Alloy : Alloy ); | |
var _ = A._; | |
A.Backbone.sync = require('ti_rest').sync | |
// | |
// MODELS | |
// | |
// | |
var Person = A.Backbone.Model.extend({ | |
url : function() { | |
return A.CFG.PEOPLE_URL + "/" + this.id | |
} | |
}); | |
var People = A.Backbone.Collection.extend({ | |
model : Person, | |
url : A.CFG.PEOPLE_URL + "/?" | |
}); | |
return { | |
"Person" : Person, | |
"People" : People, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment