Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

minChars: 0, will show all results on focus of the field #869

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions src/jquery.tokeninput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* Licensed jointly under the GPL and MIT licenses,
* choose which one suits your project best!
*
* EDITED by antonio.fortunato
* here the fork: https://github.com/ilFortu/jquery-tokeninput
* enabled to show all results when the option minChars:0
*/
;(function ($) {
var DEFAULT_SETTINGS = {
Expand Down Expand Up @@ -258,7 +261,16 @@
return false;
} else
if ($(input).data("settings").tokenLimit === null || $(input).data("settings").tokenLimit !== token_count) {
show_dropdown_hint();
if ($(input).data("settings").minChars == 0) {

// set a timeout just long enough to let this function finish.
setTimeout(function () {
do_search();
}, 5);
} else {

show_dropdown_hint();
}
}
token_list.addClass($(input).data("settings").classes.focused);
})
Expand Down Expand Up @@ -950,7 +962,7 @@
function do_search() {
var query = input_box.val();

if(query && query.length) {
if ((query && query.length) || $(input).data("settings").minChars == 0) {
if(selected_token) {
deselect_token($(selected_token), POSITION.AFTER);
}
Expand Down