Saswat
Saswat

Reputation: 12846

Search issue on chosen dropdown using jQuery

I am implementing chosen dropdown in my project. But I have some problem which I want to solve.

Before proceeding, let me give you the jQuery fiddle:

http://jsfiddle.net/jHvmg/278/

Now I have a dropdown like this

<select id="drp_menu">
    <option value="Option 1">Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Option 3">Option 3</option>
    <option value="Option 4">Option 4</option>
    <option value="Option 5">Option 5</option>
</select>

As you can see in the fiddle:

1) If I write "Opt" in the searchbox then the list is filtered showing all the options.

2) If I write " 1" it shows "Option 1"

3) If I write "1" it shows "Option 1"

4) If I write "ptio" then it states "No results"

5) If I write "tio" then it states "No result"

I want to results if words typed in the searchbox matches.

Upvotes: 1

Views: 410

Answers (2)

Gulfaraz Rahman
Gulfaraz Rahman

Reputation: 407

Replace

$('#drp_menu').chosen();

with

$('#drp_menu').chosen({search_contains:true});

Here is a fiddle

Just look for the documentation for configuration options like this

Upvotes: 1

Vikrant
Vikrant

Reputation: 5046

add { search_contains: true } and Enjoy :)

JS Code:

$(document).ready(function()
{
   $('#drp_menu').chosen({ search_contains: true });                      
});

Demo

Upvotes: 3

Related Questions