-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It is possible to render a different template on runtime? #236
Comments
Yeah, you can't change templates once an instance has been rendered. You can change partials, however, up until the point that they get rendered, so something like this (contrived example) might work... <div class='container'>
{{#showContent}}
{{>content}}
{{/showContent}}
</div> var UserCreateView = AbstractFormView.extend({
el: 'main',
template: mainTemplate(),
partials: {
content: before()
},
showConfirmation: function() {
this.set( 'showContent', false ); // teardown 'before'
this.partials.content = after(); // change partial
this.set( 'showContent', true ); // re-render, this time with 'after'
}
}); Not especially pretty, I'll grant you. Am thinking about allowing expression syntax in partials, so you could do something like <div class='container'>
{{> ready ? "after" : "before" }}
</div> Haven't worked out the details yet though. |
I see. I will give this a try for another view. Partials are really very handy here. Many thanks again! |
+1 on dynamic partials. Is there any reason to not just make them another dynamic attribute on the viewmodel? As in Anyway, dynamic partials would be very nice for making SPAs with Ractive. |
My aim is to call
showConfirmation()
which should change the template. Something like that but it is not working, nothing happens ...Any clues?
The text was updated successfully, but these errors were encountered: