【问题标题】:Passing and Accessing multiple values in Jquery template Template Composition在 Jquery 模板模板组合中传递和访问多个值
【发布时间】:2013-03-06 12:15:38
【问题描述】:

我正在使用 Jquery-template 来呈现页面,我正在使用模板组合来迭代和显示页面。

{{if simulateBomPageData.groupNames}}
   {{each simulateBomPageData.groupNames}}
     {{tmpl($value,simulateBomPageData.materialData.characterAttributesData.attributeMap[$value],$index) "#characters_group"}}
   {{/each}}
{{/if}}

我的子模板如下所示

<script id="characters_group" type="text/x-jQuery-tmpl">
   {{=$index}}" {{=$value}}(Value from fro each loop)  
the entry in the map 
and the {{=$index}}
    </script>

请告诉我如何访问和传递这些值

【问题讨论】:

    标签: jquery jquery-templates


    【解决方案1】:

    我自己找到了答案,如下所示

    function My_Class(name,object1,object2)
    {
        this.name=name;
        this.object1=object1;
        this.object2=object2;
    }
    

    将值传递给模板

    {{tmpl(new My_Class("Name",obj1,obj2)) "#characters_group"}}
    

    您可以访问模板内的值,如下所示

    <script id="characters_group" type="text/x-jQuery-tmpl">
        Name: {{= name}}
        Object1: {{= object1}}
        Object2: {{= object2}}
    </script>
    

    【讨论】:

      猜你喜欢
      • 2018-09-03
      • 2012-07-08
      • 2019-04-26
      • 2011-05-28
      • 2012-04-06
      • 2012-03-28
      • 2021-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多