Created
July 6, 2015 03:50
-
-
Save luiselizondo/3e9ea3e2f7295911c7fd to your computer and use it in GitHub Desktop.
Master Detail Model Binding in Appcelerator
This file contains hidden or 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 args = arguments[0] || {}; | |
function main() { | |
var $model = args.model; | |
var model = $model.toJSON(); | |
var collection = Alloy.Collections.book; | |
var book = Alloy.createModel("book", $model); | |
book.fetch({id: modelId}); | |
book.on("fetch", function(data) { | |
console.log(data); | |
}); | |
} | |
main(); | |
This file contains hidden or 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
Links with more information: | |
http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_XML_Markup-section-35621528_AlloyXMLMarkup-CollectionElement | |
http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Data_Binding |
This file contains hidden or 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
// $model is a special variable that has access to the TableViewRow element | |
function onClick(e) { | |
var detailWindow = Alloy.createController("detail", { | |
model: $model | |
}).getView(); | |
// Alloy.Globals.homeTab is set in index.js to the Tab opened | |
Alloy.Globals.tabGroup.activeTab.open(detailWindow, {animated: true}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment