我有一个布局,但因为它们不是已知无法定义预先其所有区域。
I have a layout, but cannot define all of its regions in advance because they are not known.
所以后来的ItemView控件创建,我想使用视图的ID作为区域的名称在布局中创建一个新的区域,所以我可以然后说:
So later on an ItemView is created and I'd like to create a new region in the layout using the view's ID as the region's name so I can then say:
layout.dynamicRegionName.show(newItemView);但这里存在循环依赖。
But there is cyclic dependency here.
我没有渲染的看法,所以我不能让在布局的号召,用于.addRegion到DOM元素的引用()
I haven't rendered the view yet, so I cannot make a reference to its DOM element to be used in the layout's call to .addRegion()
我无法呈现它,precisely,因为我希望它得到重视通过动态添加区域DOM树通过调用.show()
I cannot render it, precisely because I want it to get attached to the DOM tree through the dynamically added region by calling its .show()
@DerickBailey在GitHub上Marionette.Layout文档我相信这是在具有例如一个错误: layout.show(新MenuView());
@DerickBailey In the Marionette.Layout docs in github I believe there is an error in the example that has: layout.show(new MenuView());
但在技术上,这是接近我们需要在这里即如何能够做到:
but technically this is close to what we'd need here i.e. to be able to do:
layout.addRegion(VAR_WITH_NEW_REGION_NAME, aViewInstance);和有这种添加一个新的区域到布局呈现里面直接视图实例。
and have this add a new Region into the layout rendering inside it directly the view instance.
我缺少其他一些明显的方式来实现这一目标?那是一个已知的缺少的功能?有没有理由不拥有它?
Am I missing some other obvious way to achieve this? Is that a known missing functionality? Is there a reason not to have it?
我知道这previous问:Dynamically添加/删除地区布局但没有看到任何明确的/肯定的答案吧。
I'm aware of this previous Q: "Dynamically add/remove regions to a layout" but don't see any clear/definite answer to it.
推荐答案木偶V1.0(V1.0.2最新的是,现在)支持动态的布局区域。
Marionette v1.0 (v1.0.2 is latest, right now) supports dynamic regions in Layouts.
var MyLayout = Marionette.Layout.extend({ template: "#some-template" }); var layout = new MyLayout(); layout.render(); layout.addRegion("someRegion", "#some-element"); layout.someRegion.show(new MyView());更多推荐
动态添加地区木偶布局
发布评论