(模态)循环中的组件

(Modal) Component in Loop

我正在为 Ractive.js 使用 modal component 以及一些自己编写的组件。

在我想在循环中使用它们之前,它们都非常有用:

{{# buildingTypes:index}}
    <button type="button" class="button full xs" on-click="@this.set('open_modal', true)">choose</button>

    {{#if index == 0}}
        <modal title="My first modal" basedon="{{open_modal}}">
            <p>Hello World!</p>
        </modal>
    {{/if}}
{{/buildingTypes}}

如果我将 <modal> 移到循环之外,模态将再次运行。 我现在的假设是,该组件在循环内是未知的。

如何让组件在循环内工作?

好的,我现在可以使用了。

对于模态组件,我需要启用选项 live控制模态是动态呈现还是隐藏在 DOM 中。

对于我的自定义组件,我需要更新我的 Ractive 实例 ractive.update('buildingTypes')