Last active
December 20, 2015 20:29
-
-
Save knownasilya/6190792 to your computer and use it in GitHub Desktop.
Ember ContainerView
This file contains hidden or 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
<script type="text/x-handlebars" data-template-name="firstForm"> | |
First form | |
</script> | |
<script type="text/x-handlebars" data-template-name="secondForm"> | |
Second form | |
</script> | |
<script type="text/x-handlebars" data-template-name="thirdForm"> | |
Third form | |
</script> |
This file contains hidden or 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
App.FirstFormView = Ember.View.create({ | |
templateName: 'firstForm' | |
}); | |
App.SecondFormView = Ember.View.create({ | |
templateName: 'secondForm' | |
}); | |
App.ThirdFormView = Ember.View.create({ | |
templateName: 'thirdForm' | |
}); |
This file contains hidden or 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
App.IndexRoute = Ember.Route.extend({ | |
model: function(){ | |
return [ | |
{id: 0, value: 'Form 1' }, | |
{id: 1, value: 'Form 2' }, | |
{id: 2, value: 'Form 3' } | |
]; | |
} | |
}); |
This file contains hidden or 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
App.IndexView = Ember.View.extend({ | |
selectedValue: null, | |
forms: [ | |
App.FirstFormView, | |
App.SecondFormView, | |
App.ThirdFormView | |
], | |
formsView: Ember.ContainerView.create({}), | |
changeForm: function () { | |
var forms = this.get('forms'), | |
id = this.get('selectedValue'); | |
this.formsView.set('currentView', forms.objectAt(id)); | |
}.observes('selectedValue') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment