Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deselectAll should do so in singleselect as well #587

Merged
merged 1 commit into from
Oct 14, 2015
Merged

deselectAll should do so in singleselect as well #587

merged 1 commit into from
Oct 14, 2015

Conversation

Nithyaduruvan
Copy link
Contributor

Changing the value of a single select dropdown using 'select' method does not clear the previous values because, deselectAll method won't deselect radio button's selections. It handled only checkboxes. So removed the checkbox specific filter in jquery selector.

Changing the value of a single select dropdown using 'select' method does not clear the previous values because, deselectAll method won't deselect radio button's selections. It handled only checkboxes. So removed the checkbox specific filter in jquery selector.
davidstutz added a commit that referenced this pull request Oct 14, 2015
deselectAll should do so in singleselect as well.
@davidstutz davidstutz merged commit f812c3e into davidstutz:master Oct 14, 2015
@markusd1984
Copy link

markusd1984 commented Nov 29, 2022

Any update on this for another workaround to enable clearing a single select? @davidstutz

I was hoping to insert something into onChange so it executes some code based on selected option and automatically clear the selection again.

For now I was thinking of using a dirty approach searching for the active class and remove it, which isn't fully working yet.
wondering if there is a better one.

document.getElementsByClassName('multiselect-option dropdown-item active')[0].classList.remove("active");

UPDATE:
The only workaround I found working is to execute

$('#select-single').multiselect({
$("#example-select-single").val('').multiselect();

var elements = document.getElementsByTagName("input");

for (var i = 0; i < elements.length; i++) {
        if (elements[i].type == "radio") {
            elements[i].checked = false;
        }
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants