Aravind
Aravind

Reputation: 2198

Passing and Accessing multiple values in Jquery template Template Composition

I am using Jquery-template to render a page, where I am using Template Composition to iterate and display a page.

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

And my sub template looks as below

<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>

Please let me know how to access and pass these values

Upvotes: 3

Views: 2026

Answers (1)

Aravind
Aravind

Reputation: 2198

I found the answer myself as below

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

To pass the values to template

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

And you can access the values inside the template as below

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

Upvotes: 2

Related Questions