Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Forked from ericf/gist:3666772
Created September 7, 2012 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjmiller/3667321 to your computer and use it in GitHub Desktop.
Save brianjmiller/3667321 to your computer and use it in GitHub Desktop.
Using Y.ModelConsumer
// assumes existence of Y.UserModel
YUI.add('user-view', function (Y) {
Y.UserView = Y.Base.create('userView', Y.View, [ Y.ModelConsumer ], {
template: Y.Handlebars.templates['user'],
initializer: function () {
var user = this.get('user');
this.after({
'user:change': this.render
});
},
render: function () {
var content = this.template(this.get('user').getAttrs());
this.get('container').setHTML(content);
return this;
}
},
{
ATTRS: {
user: {
value: null,
setter: '_setM',
mClass: Y.UserModel
}
}
}
);
}, '0.0.1', {
requires: ['handlebars-base', 'view', 'templates', 'gallery-model-consumer']
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment