How to retrieve value entered in EmberJs ContainerView's Child views

Hello Everyone

I have been looking for solution since last 2 - 3 day. have gone through many posts (all those reference link etc are in this gist ). But still unable to find a correct solution.

I am using ember CLI, emberjs 1.8.0 release and I am trying to build a dynamic view. As per various reference and suggestions on the web. I planned to use ContainerView and ChildViews as, I have to dynamically add some textfields on every click of ADD button on my main view.

I am able to add the childViews in the containerView. However I am facing issue with data retrival. I am not able to get data in my controller. Data which i have entered in the each child view. I think because controller and ContainerView has not direct relation.

Here is the JSBin of what I am doing

I want to get value of all the dynamically added WIDTH fields

Hope to hear back soon !! Thanks in advance

I would like to help you, but I do not understand your question. Can you please explain what you mean by data retrieval and getting data in the controller.

Hi Kgish,

Thank you for the reply.

I hope you have seen the attached jsbin, In that I have shown that i am adding multiple child to containerView and those child have one Textfield in which user can enter Data. Now in controller I want to get that Textfield value.

I hope it is clear now?


I think it’s important to know what you’re trying to achieve since it’s likely I can offer a better solution than just getting this jsbin to work.

What I’ve gathered:

  1. You want to ability to add new rows
  2. Each row would contain a textbox
  3. The value bound to that textbox should be accessible from the controller

JS Bin - Collaborative JavaScript Debugging here is what you’ve described.

Hi Jason

Thank you for the reply Yes I want the similar functionality which you have explained above. I saw the JSBIN which you have created unfortunately when I click GetWidth I am not getting dynamically added with. I just see 1,2,3, as I added 5-6 textboxes and added value to those.

I would like to get value of added all dynamic fields in controller. Also in my case I am having little more complex design. Where when user click on add row i will add one row with four textbox and so on,

Thank you so much Jason! I will give it a try in my application and update you how it goes

Thanks a ton :+1:

@jasonmit, my understanding is that Ember.View is going away at some point in the near future. How would we implement something like this in an Ember.View-less world?

This is one of the more frustrating aspects about Ember: Current devs who are “in the know” talking about certain features being deprecated soon and warn new comers not to use them but fail to concisely offer proper alternatives or “better” practices to future-proof current code. Any insight on that would be appreciated.

The index view and controller would be come the “index” component. The story on how the router will create these components instead of views would require some work on the router’s renderTemplate hook (among various other places).

But honestly, I wouldn’t start building software today with this future goal in mind – Ember.View will be around for a long time. It’s not something they plan to deprecate and immediately make obsolete. It will be incremental and there will be a migration path.

An example, excluding the changes to index view/controller: JS Bin - Collaborative JavaScript Debugging

Wait, I might have misunderstood this- is it actually the plan to move away from views? I know that controllers are either going to get rolled into routeable components or split off into services, but why get rid of custom views? You can use components to accomplish all the same stuff that views do, but they’re kind of overkill for something like a click handler. That would also give us routeable components, application-reusable components, and generally reusable components. I’m getting uncomfortable with how overloaded that word is getting. Do we need to throw out the architecture baby with the hard-to-learn bathwater?