Skip to content

Instantly share code, notes, and snippets.

@CheezItMan
Last active May 27, 2017 21:54
Show Gist options
  • Save CheezItMan/ebd6a77aab299aa247ea3e9b1164dd1a to your computer and use it in GitHub Desktop.
Save CheezItMan/ebd6a77aab299aa247ea3e9b1164dd1a to your computer and use it in GitHub Desktop.
import Backbone from 'backbone';
import _ from 'underscore';
import $ from 'jquery';
import Task from '../models/task.js';
var TaskView = Backbone.View.extend({
initialize: function(params) {
this.template = params.template;
},
render: function() {
var compiledTemplate = this.template(this.model.toJSON());
this.$el.html(compiledTemplate);
return this;
}, // render
events: {
'click button.alert': "deleteTask",
"click button.success": "toggleComplete"
},
deleteTask: function(e) {
this.model.destroy();
},
toggleComplete: function(e) {
this.model.toggleComplete();
this.render();
}
});
export default TaskView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment