A Backbone.js Playground
A simple playground for learning backbone.js without having to install or configure anything yourself.
by rvaldez
HTML
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>
JavaScript
var AppointmentView = Backbone.View.extend({
template: _.template('<span><%= title %></span>'+
'<a href="#"> Cancel </a>'),
events:{
'click a' : function(){
this.model.cancel();
}
},
render: function(){
this.$el.html(this.template(this.model.toJSON()));
}
});
var AppointmentModel = Backbone.Model.extend({
cancel: function(){
this.set({cancelled:'true'});
}
});