Skip to content

Commit

Permalink
Fixed issue where all suggested tags are already in the list.
Browse files Browse the repository at this point in the history
  • Loading branch information
tholder committed Aug 23, 2010
1 parent 9e1e10b commit bc3a890
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
53 changes: 53 additions & 0 deletions demo.html
@@ -0,0 +1,53 @@
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>

<script type="text/javascript" src="src/jquery.tokeninput.js"></script>

<link rel="stylesheet" href="styles/token-input.css" type="text/css" />
<link rel="stylesheet" href="styles/token-input-facebook.css" type="text/css" />


<script type="text/javascript">
$(document).ready(function() {
$("#tokenize").tokenInput("http://loopj.com/tokeninput/tvshows.php", {
hintText: "Type in the names of your favorite TV shows",
noResultsText: "No results",
searchingText: "Searching...",
requiresMatch: false,
suggestedTags: [{id: 'tag1', name: 'tag1', size: 1}, {id: 'tag2', name: 'tag2', size: 2}],
focusHint: false
});

$("#tokenize2").tokenInput("/tokeninput/tvshows.php", {
classes: {
tokenList: "token-input-list-facebook",
token: "token-input-token-facebook",
tokenDelete: "token-input-delete-token-facebook",
selectedToken: "token-input-selected-token-facebook",
highlightedToken: "token-input-highlighted-token-facebook",
dropdown: "token-input-dropdown-facebook",
dropdownItem: "token-input-dropdown-item-facebook",
dropdownItem2: "token-input-dropdown-item2-facebook",
selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
inputToken: "token-input-input-token-facebook"
}
});
});
</script>
</head>

<body>
<h1>Jquery Tokenizing Autocomplete Input</h1>

<div>
<h2>List style</h2>
<input type="text" id="tokenize" name="blah" />
</div>

<div style="clear:left">
<h2>Facebook style</h2>
<input type="text" id="tokenize2" name="blah2" />
</div>
</body>
</html>
7 changes: 5 additions & 2 deletions src/jquery.tokeninput.js
Expand Up @@ -9,7 +9,6 @@
* TH - 2010-08-23 - Added ability to have arbitary tags that don't require a match from the list.
* Added requiresMatch options to suppor this. Defaults to original Tokenizing Autocomplete functionality.
* Also added focusHint so it doesn't always show hint when focusing the input. Again, defaults to orignal functionality.
* TH - 2010-08-23 - Added suggested tag functionality to load in a tag cloud of recommended tags for selection.
*/

(function($) {
Expand Down Expand Up @@ -280,7 +279,7 @@ $.TokenList = function (input, settings) {

//Should the whole ul be removed?
if($('li',this).length==0) {
$(this).parents('div.'+settings.classes.suggestedTags).remove();
$(suggested_tags_container).remove();
}
return false;

Expand Down Expand Up @@ -374,6 +373,10 @@ $.TokenList = function (input, settings) {
}

}

if($('li',suggested_tags).length==0) {
$(suggested_tags_container).remove();
}
}

}
Expand Down

0 comments on commit bc3a890

Please sign in to comment.