Skip to content

Instantly share code, notes, and snippets.

@rkamradt
Created June 4, 2014 18:03
Show Gist options
  • Save rkamradt/d6ca7313fa65e06ac70f to your computer and use it in GitHub Desktop.
Save rkamradt/d6ca7313fa65e06ac70f to your computer and use it in GitHub Desktop.
Backbone.js hello world. No additional files needed
<!DOCTYPE>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="http://backbonejs.org/backbone-min.js"></script>
<script>
var router = Backbone.Router.extend({
routes: {
'': 'home'
},
initialize: function() {
},
home: function() {
this.homeView = new homeView;
this.homeView.render();
}
});
var homeView = Backbone.View.extend({
el:'body',
template: _.template('Hello World'),
render: function() {
this.$el.html(this.template({}));
}
});
var app;
$(document).ready(function() {
app = new router;
Backbone.history.start();
})
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment