diff --git a/demo_tabindex.html b/demo_tabindex.html
new file mode 100644
index 00000000..6c8050cb
--- /dev/null
+++ b/demo_tabindex.html
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
jQuery Tokeninput Demos
+
+
Tab index demo
+
+
+
+
+
+
+
+
+
+
Tab index demo in a form
+
+
+
+
+
+
diff --git a/src/jquery.tokeninput.js b/src/jquery.tokeninput.js
index 05e01d20..c2cf7dbf 100644
--- a/src/jquery.tokeninput.js
+++ b/src/jquery.tokeninput.js
@@ -86,7 +86,6 @@ var KEY = {
COMMA: 188
};
-
// Expose the .tokenInput function to jQuery as a plugin
$.fn.tokenInput = function (url_or_data_or_function, options) {
var settings = $.extend({}, DEFAULT_SETTINGS, options || {});
@@ -297,7 +296,7 @@ $.TokenList = function (input, url_or_data_or_function, settings) {
if(event.keyCode == KEY.TAB && !$(input_box).val().length) {
hide_dropdown();
- $(this).blur();
+ // let the browser handle the tab key properly if user is trying to tab through or out
return true;
}
@@ -342,6 +341,9 @@ $.TokenList = function (input, url_or_data_or_function, settings) {
input_box.blur();
});
+ // Carry over the tab index if it's set
+ input_box.attr({ tabindex: hidden_input.attr('tabindex') });
+
// Keep a reference to the selected token and dropdown item
var selected_token = null;
var selected_token_index = 0;