jquery Templating with Conditionals
jquery Templating with Conditionals
Download Here
<!-- Template Container --> <div id="contactContainer"></div> <!-- Contact Template --> <script id="contactTemplate" type="text/html"> <div> Name: {{= name }} <br /> {{if phones.length}} Phone Numbers: <ul> {{each(i,phone) phones}} <li>{{= phone}}</li> {{/each}} </ul> {{/if}} </div> </script> <script src="Scripts/jquery-1.4.2.js" type="text/javascript"> </script> <script src="Scripts/jquery.tmpl.js" type="text/javascript"> </script> <script type="text/javascript"> var contacts = [ { name: "Bhaumik Patel", phones: ["415-555-2222", "415-999-9090"] }, { name: "Hardik Patel", phones: [] }, { name: "Rachit Patel", phones: ["415-555-8888"] } ]; $("#contactTemplate").render(contacts).appendTo("#contactContainer"); </script>
Download Here
jquery Templating with Conditionals
Reviewed by Bhaumik Patel
on
1:32 AM
Rating: