Skip to content

Instantly share code, notes, and snippets.

@juandopazo
Last active December 16, 2015 07:28
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 juandopazo/5398897 to your computer and use it in GitHub Desktop.
Save juandopazo/5398897 to your computer and use it in GitHub Desktop.
Lazy Views pattern
YUI().use('app', function (Y) {
var MyApp = Y.Base.create('myApp', Y.App, [], {
views: {
person: {
type: 'PersonView'
}
},
showPerson: function () {
var self = this.set('loading', true);
// ask for the module containing the view
Y.use('person-view', function () {
// the view is now available, so just create it
self.showView('person', {
model: self.get('model')
});
});
}
}, {
ATTRS: {
loading: {
value: false
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment