jQuery UI组合框ONCHANGE [英] jquery UI Combobox ONCHANGE
问题描述
如何在jqueryUI组合框中附加onchange函数?这是我的代码:
$(".cmbBox").combobox({
change:function(){
alert($(this).val());
}
});
值更改时,它将提醒更新的值.
请帮忙..:)
组合框示例源在示例中就可以了.我将通过修改这样的源代码来触发基础选择的change
事件(在插件内部的自动完成初始化中更改select
事件处理程序):
/* Snip */
select: function( event, ui ) {
ui.item.option.selected = true;
self._trigger( "selected", event, {
item: ui.item.option
});
select.trigger("change");
},
/* Snip */
,然后为select
的常规change
事件定义事件处理程序:
$(".cmbBox").change(function() {
alert(this.value);
});
不幸的是,这与正常的select.change
事件不能完全相同:即使您从组合框中选择相同的项目,它也会触发.
在此处尝试: http://jsfiddle.net/andrewwhitaker/hAM9H/ >
how can I attach an onchange function in a jqueryUI combobox? Here is my code:
$(".cmbBox").combobox({
change:function(){
alert($(this).val());
}
});
When the value changes, it will alert the updated value.
Any help please.. :)
The combobox example source is all right there in the example. I'd trigger the change
event of the underlying select by modifying the source code like this (changing the select
event handler inside autocomplete initialization inside the plugin):
/* Snip */
select: function( event, ui ) {
ui.item.option.selected = true;
self._trigger( "selected", event, {
item: ui.item.option
});
select.trigger("change");
},
/* Snip */
and then define an event handler for the regular change
event of the select
:
$(".cmbBox").change(function() {
alert(this.value);
});
Unfortunately this won't work exactly the same way as the normal select.change
event: it will trigger even you select the same item from the combobox.
Try it out here: http://jsfiddle.net/andrewwhitaker/hAM9H/
这篇关于jQuery UI组合框ONCHANGE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!