I need a jQuery plugin for searching a large select box with 10 to 1000 options in it. http://harvesthq.github.com/chosen/ appeared to be viable at first, but I need to alter its functionality or an alternative plugin.
I have a series of select boxes, ranged from 10 to 1000 options. I need a way to provide a filter of the select box when the user types in a string that matches what option they are looking for. I found http://harvesthq.github.com/chosen/ which looks great, is functional, and easy to implement with my current html.
My only problem is that the search matches only on the start of words, and not in the middle of words. See the first example on the Chosen webpage, “Alba” matches “Albania” but “bania” does not match “Albania”. I need a solution where “bania” will match “Albania”, since in my select list most of the options are differentiated by a number at the end. Does anyone have experience with altering Chosen to have this functionality, or is there a different jQuery plugin that provides this functionality while also looking good, functional, and easy to implement? I’ve searched and found other plugins but they either don’t have a nice style or they seem more difficult to implement.
Wow, this is the first I’ve heard of Chosen and it’s pretty awesome!
Basically I found this line (chosen.jquery.js line 732):
And just removed the ‘^’ as follows:
Doing this, I found that in the demo, “bania” will now find Albania.
Of course, this is 15 minutes of looking… a few other things you may want to think about:
maybe winnow_results should be completely re-written to suit, for example with the above change the line starting with
} else if (option.html.indexOf(” “) >= 0
is now redundant
‘hope this helps