Skip to content

Instantly share code, notes, and snippets.

@walski
Forked from ahx/app.js
Created October 23, 2010 20:58
Show Gist options
  • Save walski/642689 to your computer and use it in GitHub Desktop.
Save walski/642689 to your computer and use it in GitHub Desktop.
/*global Handlebars */
// "jsonp!/user/123?callback=?", "text!/user.mustache"
var userData = {
name: "Thorben"
};
//var userData = Model.new({
// name: "Thorben"
//});
require(
["text!user.mustache", "handlebars"],
function(userTemplate) {
var view = Handlebars.compile(userTemplate);
$("#app").html(view(userData));
//$(userData).bindToView(view);
$(userData).bind("changeData", function() {
$("#app").html(view(userData));
});
}
);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Megagut</title>
<script src="requireplugins-jquery-1.4.3.js" data-main="app.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="app">
</div>
</body>
</html>
<div id="user">
Hi {{name}}
</div>
<input type="text" name="name" value="" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment