In below fiddle, I have a bootstrap modal and there is a Select Users MultipleSelect.
I need to clear the selection on modal close, like set the dropdown to defaults without any selection.
For example, if I select user 1 and user 2, then on modal close, none should be selected. The previous selection must be gone.
The code I am trying isn't helping me out and neither are any posts here on stack overflow.
A little that I tried is this :
$("#usersDropDown option:selected").attr("checked",false);
And this :
$("#usersDropDown option:selected").attr("selected",false);
And also this:
$("#usersDropDown option:selected").removeAttr("checked");
Please guide me what should I do ?
You can use the following code to reset the form data and the multi select box in the drop-down on bootstrap modal window to clear contents.
$('#shareLocationModal').on('hidden.bs.modal', function(){
$('#usersDropDown').multipleSelect('refresh'); // to reset the multi select users dropdown
$(this).find('form')[0].reset(); // To reset form fields
})