- Compare with: https://gist.github.com/timanrebel/5643468
- Read more at: http://fokkezb.nl/2013/05/27/bind-existing-model
-
-
Save FokkeZB/5655579 to your computer and use it in GitHub Desktop.
Workaround for binding existing models in 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 characters
// Reference to the singleton | |
var someUser = Alloy.Models.user; | |
// Maybe fetch some existing data from the store | |
someUser.set('id', '1234'); | |
someUser.fetch(); | |
setInterval(function () { | |
someUser.set('name', (new Date).toString()); | |
}, 1000); | |
function openProfile() { | |
Alloy.createController('profile'); | |
} | |
$.index.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 characters
<Alloy> | |
<Model src="user" /> | |
<Window> | |
<Button onClick="openProfile" title="Open profile" /> | |
</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 characters
$.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 characters
<Alloy> | |
<Window> | |
<Label id="name" text="{user.name}" /> | |
</Window> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this doesn't work anymore