Skip to content

Instantly share code, notes, and snippets.

@hustKiwi
Created June 15, 2012 08:27
Show Gist options
  • Save hustKiwi/2935394 to your computer and use it in GitHub Desktop.
Save hustKiwi/2935394 to your computer and use it in GitHub Desktop.
var ListView = Backbone.View.extend({
tagName: 'div',
className: 'list',
events: {
'click li': 'clickItem',
'keypress': 'deleteOnKeypress'
},
clickItem: function(e) {
var $target = $(e.target);
$target.addClass('selected');
this.selected = $target.text();
},
deleteOnKeypress: function(e) {
if (e.keyCode === 8) {
this.$el.find('.selected').remove();
}
}
}
var listView = new ListView();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment