Link to home
Start Free TrialLog in
Avatar of sanagarwl
sanagarwl

asked on

iterate thru jquery template

My json object has multiple categories i.e

[{"Category":"High School",
"Schools":
[.....................

            ]
},

{"Category":"Middle School",
"Schools":
[.....................

            ]
}]

How do I get all the categories where I have  ${Category}. Right now for each category a fresh dropdown div is created for each school category.

<script id="Districtstemplate" type="text/x-jquery-tmpl"> 
    <div class="dropdown">
    
    <div class="submenu1">
        
       

    <div class="submenu">
    
    <div class="header">
        Categories
    </div>
           
            
            
        
    <ul class="root">
   
    <li ><a href="#" >
         
             ${Category}
        
                                       </a></li>
             
            </ul>
       
        
        </div>
 </div>
 </div>
    
</script>

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

What are you trying to achieve?
Are you saying you want a single indented dropdown, such as is often used for forum 'Jump to Page' dropdowns?
Avatar of sanagarwl
sanagarwl

ASKER

here's what the dropdown looks like

Middle School
Elementary school
Junior school
....
....

mousing over Middle school shows all the Middle schools, same with Elementary Schools ...
Okay...so that sounds like an expanding dropdown on mouseover; I'd start with looking at navigation subtab trees, and modifying one to fit your needs. Should be fairly straightforward from the base code. It sounds like all you'd need to do is add the dynamic navigation options to it from your json.
I have my json object with the url - I just need to know the syntax for iterating through the category element in the json.

I could always create a parent to the category element in the json and then do

{{each categories}}
${$value.Name}
{{/each}}

But I should not have to do that - I'm looking for something like

{{each .}}
${$value.Name}
{{/each}}

and this should give me
Middle School
High School
Elementary School

I have worked with xslt transformations and doing things of this nature were quite simple but somehow jquery tmplating syntax leaves much to be desired...

thanks for looking into this
ASKER CERTIFIED SOLUTION
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks - that worked