I'm linking directly to the git for the jquery.tmpl, this is not recommended, I'm only doing it for this example, I've also tested with the js locally and I get the same issue. For some reason th开发者_Go百科e ${Variables} are not rendering, they are returning blank. I've done this before dozens of times, what am I missing???
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>[demo]</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
<script type="text/javascript" src="js/jquery.tmpl.min.js"></script>
</head>
<body>
<script type="text/javascript">
function loadTemplate() {
$.tmpl( "${name}", { "name" : "John Doe" }).appendTo( "#input" );
}
</script>
<div>
<a href="#" onclick="loadTemplate()">load</a>
<div id="input"></div>
</div>
</body>
</html>
#&^%! Figured it out, this is a grails/gsp page and they use ${} for their variable notation, which means they were trying to parse the ${} variable before the javascript could and return a value, so in the html the ${Name} variable is being rendered as ""
精彩评论