Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 16, 2014 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/8878d2309fac82458a54 to your computer and use it in GitHub Desktop.
Save devdays/8878d2309fac82458a54 to your computer and use it in GitHub Desktop.
Object JavaScript - Loading Template Using Infuser
<html>
<head>
<title>Basic Example</title>
</head>
<body>
<p>Try this in Chrome, while watching requests on the "Network" tab of the developer tools.</p>
<div>
<input id="btnTemplate" type="button" value="Say Hello!">
<span id="msg"></span>
</div>
<div id="target"></div>
<script type="text/javascript" src="Scripts/jquery-2.0.0.js"></script>
<script type="text/javascript" src="Scripts/TrafficCop.js"></script>
<script type="text/javascript" src="Scripts/infuser.js"></script>
<script>
var toggled = false;
$(function () {
$('#btnTemplate').click(function () {
infuser.defaults.templateUrl = "./Templates",
infuser.get("Hello", function (template) {
var target = $("#target");
target.hide().children().remove();
target.append($(template)).fadeIn();
if (!toggled) {
$("#msg").text("Next click uses a locally cached template");
}
})
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment