Created
June 25, 2012 12:52
-
-
Save Satyam/2988409 to your computer and use it in GitHub Desktop.
Person.View.js
This file contains 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
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'] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Creo que todavía te faltaría evitar alguna race condition si se llama a
render()
muy rápido