2

So the problem is the autocomplete combobox is initialized without the change event. I want to bind it afterwards but the documentation seems to be inadequate about the combobox.

Code that doesn't work:

$('#select').combobox();
...
$('#select').bind( "autocompletechange", function(event, ui) {
  alert('changed');
});

I am guessing the event label is wrong since the inline label on the combobox is "selected" e.g. $('#select').combobox({selected : function(ev,ui) { alert('selected'); }}); works but I can't use it that way.

So any idea what's the correct label of the event? I just can't find it in the documentation.

EDIT: Actually I found where my problem was. $('#select').combobox(); just maps a select to an autocomplete input. The input it creates has an id like id='select-autocomplete', so to bind and event to that combobox - the selector should be on this input instead on the select. So the working code:

$('#select').combobox();
    ...
$('#select-autocomplete').bind( "autocompletechange", function(event, ui) {
    alert('changed');
});
Charles Sprayberry
  • 7,741
  • 3
  • 41
  • 50
Lothar
  • 529
  • 1
  • 5
  • 19
  • What is the issue that you're experiencing? Basically, the autocompletechange event is supposed to fire when the field is blurred. (Loses focus) Are you not seeing the alert if you give the focus to another field? – evasilchenko Aug 11 '11 at 14:30

1 Answers1

0

So, I found more clear solution than binding event to created .ui-combobox-input. You should find in combobox code place where input is initialized, and find select parameter. Make changes in this part of code:

select: function( event, ui ) {
    ui.item.option.selected = true;
    that._trigger( "selected", event, {
        item: ui.item.option
    });
    that.element.trigger('change');// here is the trick
},
Pavel K
  • 496
  • 3
  • 15
  • Just for the link: a similar answer with a little more explanation can be found [here](http://stackoverflow.com/a/4761830/2098939). – Gerrit-K Jan 22 '14 at 08:06