簡體   English   中英

如何在EmberJS中的N個嵌套子級中使用parentView.template

[英]How to use the parentView.template in N nested children in EmberJS

這是我想要做的:

我想在emberjs中創建一個樹形小部件,如下所示:

    {{view UI.TreeView content="App.rootNode"}}
        {{name}} //-> content of each node, it could be <img src="{{icon}}" /> {{name}}
    {{/view}}

我面臨的問題是如何在itemViewClass中使用內部模板。

到目前為止,這是我想到的: http : //jsfiddle.net/YJ7zM/13/

相關行:

   template: Em.Handlebars.compile("{{name}} {{view UI.TreeChildrenView contentBinding=\"children\"}}")

那是我不喜歡的那行,並希望替換成更多類似的內容:

   templateBinding: "parentView.template"

問題在於,“ parentView”僅適用於樹的第一級,對於其他樹,它將是“ parentView.parentView.template”,因此繼續。

您總是可以在外部定義模板並使用templateName ...

http://jsfiddle.net/YJ7zM/14/

編輯

修改以解決第一條評論。 http://jsfiddle.net/ud3323/mgCva/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM