Skip to content

Commit

Permalink
don't handle the tab key if the tag input is empty, so that the user …
Browse files Browse the repository at this point in the history
…can tab on through a form
  • Loading branch information
aehlke committed May 31, 2011
1 parent 09f5237 commit 9f981ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Update the autocomplete to use the new jQuery UI autocomplete widget. The
current one is deprecated, though still functional.

* Add keyboard shortcuts for highlighting tags to remove them upon backspace.

2 changes: 1 addition & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css">
<link href="css/jquery.tagit.css" rel="stylesheet" type="text/css">
<!--<link href="css/tagit.ui-zendesk.css" rel="stylesheet" type="text/css">-->
<!--<link href="css/tagit.ui-zendesk.css" rel="stylesheet" type="text/css">-->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
Expand Down
6 changes: 5 additions & 1 deletion js/tag-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@

// Comma/Space/Enter are all valid delimiters for new tags,
// except when there is an open quote or if setting allowSpaces = true.
// Tab will also create a tag, unless the tag input is empty, in which case it isn't caught.
if (
event.which == $.ui.keyCode.COMMA ||
event.which == $.ui.keyCode.TAB ||
event.which == $.ui.keyCode.ENTER ||
(
event.which == $.ui.keyCode.TAB &&
self._tagInput.val() !== ''
) ||
(
event.which == $.ui.keyCode.SPACE &&
self.options.allowSpaces !== true &&
Expand Down

0 comments on commit 9f981ef

Please sign in to comment.