0

いくつかの機能を追加するだけの専用の選択コントロールビューを作成したいと思います。簡単にするために、タイトルを追加できるようにしたいと思います。

コントロール/ビュー:

window.App.ControlsSelectView = Ember.View.extend({
    templateName: 'controls/SelectView',
    title:"Hello Control",
    contentBinding: null
 });

一致するhtml:

<div class="sub_heading">
    <h2>{{title}}</h2>
</div>
<div class="inner_12 input_wrapper custom_select">
    {{view Ember.Select
           multiple="true"
           contentBinding= "contentBinding" // how to pass parameters through?
           selectionBinding="content.tempSelectedFunctions"
           optionLabelPath="content.displayname"
           optionValuePath="content.id"
    }}
</div>

使用法は次のようになります。

{{ view App.ControlsSelectView 
    contentBinding="content.data.responsibilities" 
    selectionBinding="content.tempSelectedFunctions"
    title="content.responsibilitTitle"
}}

問題は、それがそのように機能しないということです。上記は可能ですか?または、単純で再利用可能なコントロールを作成するためのより良いパターンはありますか?

4

1 に答える 1

1

この投稿は私が正しい軌道に乗るのに役立ちました:

ContentBindingからビュー内のコンテンツを取得します

コントロールビューのhtml内で、view.propertynameを使用してビューパラメータを参照する必要があります

実用的な解決策:

HTML:

<div class="sub_heading">
    <h2>{{view.title}}</h2>
</div>
{{#if view.content}}
    <div class="inner_12 input_wrapper custom_select">
        {{view Ember.Select
               multiple="view.multiple"
               contentBinding= "view.content"
               selectionBinding="view.selection"
               optionLabelPathBinding="view.optionLabelPath"
               optionValuePathBinding="view.optionValuePath"
        }}
    </div>
{{/if}}

ControlView

window.App.ControlsSelectView = Ember.View.extend({
    templateName: 'controls/SelectView'

});

使用法:

{{view App.ControlsSelectView
        title = "Function"
        multiple="true"
        contentBinding="content.data.functions"
        selectionBinding="content.tempSelectedFunctions"
        optionLabelPath="content.displayname"
        optionValuePath="content.id"

}}
于 2013-02-13T13:11:33.167 に答える