How to set resultsLimit of jQuery token input plugin?

580 views Asked by At

How to set limit to 10 that should token input plugin suggest ? I want to set limit to 10 so jquery token input plugin can suggest only 10 search.

I have tried resultsLimit: 10 in initialization function still it is not working.

Any solution ?

2

There are 2 answers

2
Rory McCrossan On

From the documentation:

resultsLimit
The maximum number of results shown in the drop down. Use null to show all the matching results. default: null

So you therefore you just need to set this property when you initialise the plugin:

$("#myInput").tokenInput('/path-to-data/', {
    resultsLimit: 10
});
0
cbros2008 On

I had the same issue and got it to work by modifying the token input JS file. Add the following pieces of code.

Line 46 : resultsLimit: null,

Line 680 : in populate_dropdown function
//Setting search limit
if (results.length > settings.resultsLimit) {
results = results.slice(0, settings.resultsLimit);
} 

Reference: https://github.com/loopj/jquery-tokeninput/issues/542