Created
June 15, 2012 08:27
-
-
Save hustKiwi/2935394 to your computer and use it in GitHub Desktop.
This file contains 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
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