Skip to content

Instantly share code, notes, and snippets.

@Satyam
Created June 25, 2012 12:52
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 Satyam/2988409 to your computer and use it in GitHub Desktop.
Save Satyam/2988409 to your computer and use it in GitHub Desktop.
Person.View.js
YUI.add('personView',function(Y){
Y.PersonView = Y.Base.create(
'personView',
Y.View,
[],
{
initializer:function(){
this.model = this.get('model');
},
render:function(){
if (this.template) {
this.get('container').setHTML(this.template(this.model.getAttrs(['name','age','height'])));
} else {
Y.io('/scripts/views/templates/Person.Template.html',{
on:{
complete:function(id,response){
this.template = Y.Handlebars.compile(response.responseText);
this.render();
}
},
context:this
});
}
return this;
}
});
}, '0.0.1', {
requires: ['base-build','handlebars', 'io-base','node-base','view', 'personModel']
});
@juandopazo
Copy link

Creo que todavía te faltaría evitar alguna race condition si se llama a render() muy rápido

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