Created
December 16, 2014 19:49
-
-
Save devdays/8878d2309fac82458a54 to your computer and use it in GitHub Desktop.
Object JavaScript - Loading Template Using Infuser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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