Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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