问题
I have the following code for JQuery multi select checkbox dropdown.
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 Code:
$("#day").change(function () {
var str = '',
busiArray = array();
$("select#day option:selected").each(function () {
str = $( this ).text();
busiArray.push(str);
});
});
回答1:
Multiple-select selectmenu is converted into a popup. That popup receives id of select
And -listbox
added to it dynamically.
Attach popupafterclose
and then run your code.
$(document).on("popupafterclose", "#day-listbox", function () {
/* code */
});
来源:https://stackoverflow.com/questions/26698343/jquery-multiselect-checkbox-dropdown-event-handling