Skip to content

Instantly share code, notes, and snippets.

@timanrebel
Last active December 17, 2015 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save timanrebel/5643468 to your computer and use it in GitHub Desktop.
Save timanrebel/5643468 to your computer and use it in GitHub Desktop.
// Fetch some User
var someUser = Alloy.createModel('User', {
id: '1234'
});
someUser.fetch();
// Create new Profile controller
var someProfile = Alloy.createController('Profile', { user: someUser });
// Change model
someUser.set('name', 'New Name');
var args = arguments || {};
/**
* Works, but you loose change listeners on the original model
*/
$.user.set(args.user.attributes);
/**
* Does not work
*/
// $.user = args.user;
$.profile.open();
<Alloy>
<Model src="User" id="user" instance="true" />
<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