?
Solved

iterate thru jquery template

Posted on 2012-09-06
7
Medium Priority
?
346 Views
Last Modified: 2012-09-10
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

0
Comment
Question by:sanagarwl
  • 3
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 38373249
What are you trying to achieve?
0
 
LVL 9

Expert Comment

by:Derek Jensen
ID: 38373252
Are you saying you want a single indented dropdown, such as is often used for forum 'Jump to Page' dropdowns?
0
 

Author Comment

by:sanagarwl
ID: 38373318
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 ...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:Derek Jensen
ID: 38373656
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.
0
 

Author Comment

by:sanagarwl
ID: 38373760
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
0
 
LVL 9

Accepted Solution

by:
Derek Jensen earned 2000 total points
ID: 38374049
Have you tried using the .each() call? Perhaps that might be what you're looking for...??
0
 

Author Closing Comment

by:sanagarwl
ID: 38385392
thanks - that worked
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question