-
-
Save tonylukasavage/8541502 to your computer and use it in GitHub Desktop.
Revisions
-
tonylukasavage revised this gist
Jan 21, 2014 . 2 changed files with 16 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,18 @@ var EVENTS = 'fetch change destroy'; var args = arguments || {}; // remove existing bindings to prevent unexpected behavior and memory leaks $.user.off(EVENTS); // add bindings to new model args.user.on(EVENTS, function() { $.name.text = args.user.get('name'); }); // probably want to delete the bindings on window close $.win.addEventListener('close', function() { args.user.off(EVENTS); }); $.win.open(); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <Alloy> <Model src="User" id="user" instance="true" /> <Window id="win"> <Label id="name" text="{$.user.name}" /> </Window> </Alloy> -
timanrebel revised this gist
May 27, 2013 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,6 @@ $.user.set(args.user.attributes); /** * Does not work */ // $.user = args.user; $.profile.open(); 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,8 @@ var someUser = Alloy.createModel('User', { }); someUser.fetch(); // Create new Profile controller var someProfile = Alloy.createController('Profile', { user: someUser }); // Change model someUser.set('name', 'New Name'); -
timanrebel created this gist
May 24, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ var args = arguments || {}; /** * Works, but you loose change listeners on the original model */ $.user.set(args.user.attributes); /** * Does not work */ $.user = args.user; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <Alloy> <Model src="User" id="user" instance="true" /> <Window> <Label id="name" text="{$.user.name}" /> </Window> </Alloy> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // Fetch some User var someUser = Alloy.createModel('User', { id: '1234' }); someUser.fetch(); var someProfile = Alloy.createController('Profile', { user: someUser }); someUser.set('name', 'New Name');