How to disable a specific option in Jquery Autocomplete combox

When I have simple drop down box

<select id="fruits">
<option value="apple">Apple</option>
<option value="orange">Orange</option>
<option value="banana" disabled="true">Banana</option>
</select>

The Banana Option is disabled in the drop down.

When I tried to use Jquery Autocomplete Combo box

$( "#fruits" ).combobox();

The Autocomplete dropdown works fine, but the option Banana ( which has disabled option set ) is not disabled.

Answers:

Answer

Assuming it's the combobox in the demo http://jqueryui.com/demos/autocomplete/

try replacing this line:

response( select.children( "option" ).map(function() {

with:

response( select.children( "option" ).not(':disabled').map(function() {

You could also use the excellent Chosen select element formatter which combines a search box with a formatted select element.

Answer

Sadly, I don't think it's possible.

Even hiding the element with display:none in css still allows it to show in the autocomplete field. Worse, once its selected there it is actually selected in the underlying select box even though it is 'disabled'.

You're only option might be to remove the element when it is disabled, and add it again if it needs to be enabled.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.