Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Feature Request #359

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ autocomplete url.
If you're using the bassistance jQuery.autocomplete, which takes extra
parameters, you can also send in options to the autocomplete plugin, as
described here.
searchWhenClick: Boolean - When true search on click by parameter %

$('#tags').tagsInput({
autocomplete_url:'http://myserver.com/api/autocomplete',
autocomplete:{selectFirst:true,width:'100px',autoFill:true}
autocomplete:{
selectFirst:true,
width:'100px',
autoFill:true,
searchWhenClick: false
}
});

You can add and remove tags by calling the addTag() and removeTag() functions.
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.tagsinput.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions src/jquery.tagsinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,18 @@
minChars:0,
width:'300px',
height:'100px',
autocomplete: {selectFirst: false },
autocomplete: {
selectFirst: false,
searchWhenClick: false
},
hide:true,
delimiter: ',',
unique:true,
removeWithBackspace:true,
placeholderColor:'#666666',
autosize: true,
comfortZone: 20,
inputPadding: 6*2
inputPadding: 6*2,
},options);

var uniqueIdCounter = 0;
Expand Down Expand Up @@ -275,7 +278,12 @@
}
});
} else if (jQuery.ui.autocomplete !== undefined) {
$(data.fake_input).autocomplete(autocomplete_options);
if(settings.autocomplete && settings.autocomplete.searchWhenClick !== undefined && settings.autocomplete.searchWhenClick){
$(data.fake_input).autocomplete(autocomplete_options).on("click", function(){$(this).autocomplete("search","%")});
} else {
$(data.fake_input).autocomplete(autocomplete_options);
}

$(data.fake_input).bind('autocompleteselect',data,function(event,ui) {
$(event.data.real_input).addTag(ui.item.value,{focus:true,unique:(settings.unique)});
return false;
Expand Down