简体   繁体   中英

Is it possible for property assignments to bubble up the controller chain in Ember.js?

I have a resource creation controller/view, and the resource belongsTo another. An element of the view is a shared Component that contains nested resource index and filter/pagination logic. I'd like to override the context of the sub-resource's indexController such that when an instance is selected, it is assigned to the parent controller rather than the controller itself.

While ember bubbles action events up the controller hierarchy, it errors out if a property is undefined. Also, it delegates properties from the view to the controller if undefined in the view.

This seems like it might be a common pattern. Perhaps implicit bubbling is not ideal, but is there a best practice (or should there be a way) to enable any undefined references to bubble up to a parent?

If the nested controllers/views are just UI elements (do not need to have special model) than I suggest to not implement special controllers for these nested views. I mean try to implement just the views and render them in a parent template using Handlebars {{#view App.YourView}} helper which binds current controller (the parent one) as a model to the view so you can access the parent model. For more info see Rendering with helpers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM