Last active
May 27, 2017 21:54
-
-
Save CheezItMan/ebd6a77aab299aa247ea3e9b1164dd1a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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