[英]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. 我有一个资源创建控制器/视图,该资源
belongsTo
另一个。 An element of the view is a shared Component
that contains nested resource index and filter/pagination logic. 视图的元素是共享
Component
,其中包含嵌套的资源索引和过滤器/分页逻辑。 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. 我想重写子资源的
indexController
的上下文,以便在选择实例时将其分配给父控制器,而不是控制器本身。
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. 如果嵌套的控制器/视图只是UI元素(不需要特殊的模型),那么我建议不要为这些嵌套的视图实现特殊的控制器。 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. 我的意思是尝试使用Handlebars
{{#view App.YourView}}
帮助程序仅实现视图并将它们呈现在父模板中,该助手将当前控制器(父{{#view App.YourView}}
)作为模型绑定到视图,以便您可以访问父模型。 For more info see Rendering with helpers 有关更多信息,请参见使用助手进行渲染
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.