Skip to content

Instantly share code, notes, and snippets.

@FokkeZB
Forked from timanrebel/Profile.js
Last active December 17, 2015 18:49
Show Gist options
  • Save FokkeZB/5655579 to your computer and use it in GitHub Desktop.
Save FokkeZB/5655579 to your computer and use it in GitHub Desktop.
Workaround for binding existing models in Alloy
// 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();
<Alloy>
<Model src="user" />
<Window>
<Button onClick="openProfile" title="Open profile" />
</Window>
</Alloy>
$.profile.open();
<Alloy>
<Window>
<Label id="name" text="{user.name}" />
</Window>
</Alloy>
@wakandan
Copy link

this doesn't work anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment