Hi,
I am working on a fairly complex Ember application and I am trying to split the app into separate components for better maintainability and also to move away from controllers as much as possible. I am quite new to ember, stiff fighting with some issues and I am not completely sure how to tackle some tasks.
The problem I am facing at the moment is a bottom-up communication between a component and the controller and specifically around validations. I have a component with some validations defined in it and input fields. I want to have a property in the controller, which resembles if the underlying component has valid data. Here is a jsbin with an example: JS Bin - Collaborative JavaScript Debugging
After quite a bit of experimenting I convinced myself that I need to use the mut
helper and use an observer to update the controller’s property. A better solution will be to have a one-way binding from the component to the controller, but I couldn’t find a way to do that. Is that possible?
Also I had to explicitly update the mut
property in the init
of the component, which is really strange. Any ideas why is that needed? You can try to remove the init
in the component and you will see how the binding breaks (controller no longer knows when the inputs are valid).
I will be thankful for any pointers and suggestions.
Thanks, Valentin