jquery-simple-combobox
jquery-simple-combobox copied to clipboard
The change event does not fire the first time a selection is made after a user enters text in the combo box
Steps to reproduce
- Enter text into the combo box
- Make a selection
- Note that the change event does not fire here
- Make another selection
- Now the change event fires
I have found that I can correct the issue by commenting out lines 723-726 as shown in the following code snippet. I'm not sure what the purpose of these lines of code is for though so I'd like to know more about the implications:
this.on('change', 'select', function (e, checkboxesMode) { // someone triggered combobox select change
var $combo = $(this).closest(cp);
var dtext = $('option:selected', this).text();
$combo.children(cp + cdisplay).val(dtext).data('value', dtext);
var $valueInput = $combo.children(cp + cvalue);
//This bit of code is causing the change event to not fire if a user first types in a value and then selects an item in the list.
// if ($valueInput.data('changed')) {
// $valueInput.data('changed', false);
// return;
// }
if (checkboxesMode) { // no slideup for checkboxes mode
updateValueInput.call($combo);
$valueInput.change();
return;
}
$valueInput.change();
slide.call($combo.children(cp + clist), 'up'); // can be triggered at the page load
});
@ben-m-lucas - I have created this fiddle that I think demonstrates what you mean:
http://jsfiddle.net/gjsjohnmurray/vgqvww6s/
I think the lines you commented out above are needed to suppress undesirable change events, for example if value is changed programmatically.
I will investigate the issue and try to provide a fix for the missing event.
@gjsjohnmurray - Yes, that fiddle does demonstrate the issue. Thank you, and let me know what you find.