Hi,
I’m currently evaluating Ember for a new app I’m building. I’m trying to understand how to do things the “Ember way” and use the framework the way it was designed. I have a question around multiple controller instances.
The app involves a lot of dynamic form generation. When selecting a form, the server returns a JSON structure that describes what controls to render. I’ve managed to make some progress by using a custom helper to render the required form element:
<div class="panel-body">
<form class="form-horizontal">
{{#each control in controls}}
{{renderControlView control}}
{{/each}}
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button {{action 'generate'}} type="button">Generate</button>
</div>
</div>...
The custom helper then uses the “render” helper to create an instance of a view, with it’s controller:
Ember.Handlebars.registerBoundHelper( 'renderControlView', function ( filter ) {
....
return Ember.Handlebars.helpers.render.apply( this, args );
});
This works.
However, lets say I have a view/controller combination for a date selection control. If I have a multiple instances of a date control on a single form, they will all share the same controller instance? Is that correct? If so, that would prevent me from including any instance-specific state on the controller, such as validation state.
What would be the best way to handle this using Ember?
Thanks