Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request loopj#113 from otaviomedeiros/master
Fixed the issue described in #50 and #53, thanks otaviomedeiros
  • Loading branch information
loopj committed Jun 10, 2011
2 parents 92bf8d8 + 86ae6e3 commit 15b223e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/jquery.tokeninput.js
Expand Up @@ -317,6 +317,7 @@ $.TokenList = function (input, url_or_data, settings) {
if(li_data && li_data.length) {
$.each(li_data, function (index, value) {
insert_token(value.id, value.name);
checkTokenLimit();
});
}

Expand All @@ -326,6 +327,16 @@ $.TokenList = function (input, url_or_data, settings) {
// Private functions
//

function checkTokenLimit(){
if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
input_box.hide();
hide_dropdown();
return;
} else {
input_box.focus();
}
}

function resize_input() {
if(input_val === (input_val = input_box.val())) {return;}

Expand Down Expand Up @@ -404,14 +415,7 @@ $.TokenList = function (input, url_or_data, settings) {
// Insert the new tokens
insert_token(li_data.id, li_data.name);

// Check the token limit
if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
input_box.hide();
hide_dropdown();
return;
} else {
input_box.focus();
}
checkTokenLimit();

// Clear input box
input_box.val("");
Expand Down

0 comments on commit 15b223e

Please sign in to comment.