How to reset a jquery multiselect checkbox dropdown -



How to reset a jquery multiselect checkbox dropdown -

i have below code. per functionality, when user chooses first radio button, no action required when user chooses sec radio button, multiselect jquery dropdown shown up. user can select checkboxes. fine. after user checks checkboxes , click on first radio button, dropdown should disappear , values should reset or in other words, checkboxes should unchecked. able create disappear using hide(), values not getting unchecked. when come back, still see old values.

<div id="radiobutton" data-role="fieldcontain" style="display: none"> <label for="flip-1">choose </label> <fieldset data-role="controlgroup"> <input type="radio" name="radio-choice-2" id="radio-choice-1" value="choice-1" /> <label for="radio-choice-1">all business catergories</label> <input type="radio" name="radio-choice-2" id="radio-choice-2" value="choice-2" /> <label for="radio-choice-2">a specific business category</label> </fieldset> </div> <div id="multicheckbox" style="display: none"> <select name="busiunit" id="day" multiple="multiple" data-native-menu="false"> <option>business unit category</option> <option value="29">abc</option> <option value="30">xyz</option> <option value="31">bcd</option> </select> </div> </div>

i using jquery hide() & show() methods, displaying , hiding dropdown. below code reading checkboxes.

$("#day").change(function(){ var str = ""; busiarray=[]; $( "select#day option:selected" ).each(function() { str = $( ).val(); busiarray.push(str); }); });

how reset dropdown ?

thanks.

listen change event radio button want, , reset value .val("") of selectmenu followed .selectmenu("refresh") re-apply styles.

note need utilize jquery mobile 1.4.5 there bug in previous versions.

$("#radio-choice-1").on("change", function () { if($(this).is(":checked")) { $("#day").val("").selectmenu("refresh"); } });

demo

jquery jquery-mobile checkbox

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -