JQuery多选复选框下拉事件处理 [英] JQuery multiselect checkbox dropdown event handling
问题描述
我有以下代码为JQuery多选择复选框下拉。
I have the following code for JQuery multi select checkbox dropdown.
当用户选择复选框时,我可以捕获事件。但我想要当用户选择复选框并关闭下拉菜单时触发事件?我不想为每个复选框选择插入DB,而是当用户选择他的复选框并关闭下拉列表?并且还应该能够检索所选的值。感谢
I can catch the event when the user selects the checkboxes. But I want the event to be fired when the user selects checkboxes and closes the dropdown ? I don't want to insert the DB for every checkbox selection , rather when the user selects his checkboxes and closes the dropdown ? And also should be able to retrieve the selected values. Thanks
<div id="multiCheckbox">
<select name="busiUnit" id="day" multiple="multiple"
data-native-menu="false">
<option>Business Unit</option>
<option value="1">Finance</option>
<option value="2">R&D</option>
<option value="3">Sales</option>
<option value="4">Inventory</option>
</select>
</div>
JS代码:
$("#day").change(function () {
var str = '',
busiArray = array();
$("select#day option:selected").each(function () {
str = $( this ).text();
busiArray.push(str);
});
});
推荐答案
多重选择选单会转换成弹出式视窗。该弹出窗口接收到的id
Multiple-select selectmenu is converted into a popup. That popup receives id of select
And -listbox
added to it dynamically.
附加 popupafterclose
,然后运行您的代码。
Attach popupafterclose
and then run your code.
$(document).on("popupafterclose", "#day-listbox", function () {
/* code */
});
这篇关于JQuery多选复选框下拉事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!