how can I attach an onchange function in a jqueryUI combobox? Here is my code:
$(\".cmbBox\").combobox({
change:function(){
alert($(this).val()
simplest way (IMHO), if you are deploying combobox as widget:
find "_create" method in widget
inside of it look for "autocomplete" (where input is managed)
add (use) "select" method to get your data: ui.item.value
(function($){
$.widget( "ui.combobox", {
// default options
options: {
//your options ....
},
_create: function() {
//some code ....
//this is input you look for
input = $( "" )
.appendTo( wrapper )
.val( value )
.addClass( "ui-state-default" )
//this is autocomplete you look for
.autocomplete({
delay: 0,
minLength: 0,
source: function( request, response ) {
//some code ...
},
//this is select method you look for ...
select: function( event, ui ) {
//this is your selected value
console.log(ui.item.value);
},
change: function( event, ui ) {
//some code ...
}
})
//rest of code
},
destroy: function() {
this.wrapper.remove();
this.element.show();
$.Widget.prototype.destroy.call( this );
}
});
This seems to work for me
if('function' == typeof(callback = ui.item.option.parentElement.onchange))
callback.apply(this, []);
just before
self._trigger("selected", event, {