Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created October 21, 2010 18:13
Show Gist options
  • Select an option

  • Save aaronmcadam/638995 to your computer and use it in GitHub Desktop.

Select an option

Save aaronmcadam/638995 to your computer and use it in GitHub Desktop.
jquery templating example
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script id="adminBarTemplate" type="text/x-jquery-tmpl">
<li><img src="${iconSrc}" alt="${area}" /><a target="_blank" href="${areaLink}">${area}<span></span></a></li>
</script>
<script type="text/javascript">
$(document).ready(function(){
var adminBarData = [
{ "iconSrc" : "src", "area" : "Page Text Manager", "areaLink" : "/admin/flex/bin/main.html" },
{ "iconSrc" : "src", "area" : "Menu Manager", "areaLink" : "/admin/flex/bin/menuManager.html" }
];
var adminBar = $( '<div/>', {
id : "adminBar",
html : '<ul></ul>'
});
$( 'div:eq(0)' ).before( adminBar ); // insert adminBar before the first div on the page
$('#adminBarTemplate').tmpl(adminBarData).appendTo( '#adminBar ul' ); // append in the template to the adminBar ul
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment