动态添加地区木偶布局

编程入门 行业动态 更新时间:2024-10-22 23:03:23
本文介绍了动态添加地区木偶布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个布局,但因为它们不是已知无法定义预先其所有区域。

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());
  • 更多推荐

    动态添加地区木偶布局

    本文发布于:2023-11-11 18:09:07,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1579189.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:木偶   布局   地区   动态

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!