Skip to content

Commit

Permalink
Switched onchange event to onkeyup event in order to respond only to …
Browse files Browse the repository at this point in the history
…Enter key
  • Loading branch information
tomerdmnt committed Oct 11, 2012
1 parent 7add81c commit bbf0268
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ function TagInput(input, opts) {
input.parentNode.removeChild(input)
this.view.container.appendChild(input)

input.onchange = function (e) {
e.preventDefault()
self.addtag(e.target.value)
e.target.value = ''
input.onkeyup = function (e) {
if (e.which === 13) {
e.preventDefault()
self.addtag(e.target.value)
e.target.value = ''
}
}
}

Expand Down

0 comments on commit bbf0268

Please sign in to comment.