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

Issue with deselectAll and radio multiselect (multiple = false) #473

Open
zephyx opened this issue Jan 22, 2015 · 7 comments
Open

Issue with deselectAll and radio multiselect (multiple = false) #473

zephyx opened this issue Jan 22, 2015 · 7 comments
Labels

Comments

@zephyx
Copy link

zephyx commented Jan 22, 2015

Hi,

When I try to clearSelection my multiselect the label of the multiselect is properly reset but when I open my multiselect the previous radio button chosen is still checked.
If I am not wrong I think it probably comes from the deselectAll function where only the checkbox case is handled.

I have added a:

var type = this.options.multiple === true ? "checkbox" : "radio";
And I use this variable inside the js selectors (ie: $("li input[type='"+type+"']:enabled" ) and it seems to work. It's important for me because I trigger something on the change event :). If a value is already selected we can't fire the change event except if we select an other option and come back later.

@davidstutz
Copy link
Owner

Might be related to #129! I will check this, however, as stated in #129 and as I remember, a part of this problem is also due to browser behavior.

@davidstutz davidstutz added the bug label Feb 12, 2015
@zephyx
Copy link
Author

zephyx commented Feb 17, 2015

If the problem is the browser behaviour, may be it could at least select the first radio option by default when we deselectAll ?
In this case it would correspond to the default state of a select on all browser like if nothing had been selected first.

@kayday
Copy link

kayday commented Feb 17, 2015

I had to do a refresh: $('#myMS').multiselect('refresh');
to get rid of the previously selected item.

@EoinGriffin-AI
Copy link

+1
In our case, we have several dropdowns, and 1 button that clears them all. Unfortunately, after clearing (using 'clearSelection()') them it's not possible to re-select the previous selection (unless you select something else first).

To fix this, I've swapped out the 'change' events for 'click' events.
That fixes the issue, and also fixes a related bug where the dropdown won't close if you click on an option that's already selected.

Is there a reason why the 'change' event is used instead of the 'click' event?
I don't see any downside to switching to 'click'.

@davidstutz
Copy link
Owner

Not sure whether the click event screws up keyboard support. Might check it first before switching.

@moghazali-iomosaic
Copy link

@zephyx did your provided solution ever got into the source code and released as I am facing the same issue in 2020 while using the plugin.

I used various combinations of .val(''), .multiselect('resfresh'), .multiselect('deselectAll', false), and .multiselect('updateButtonText') as suggested in docs and many issues and although a specific combination resolves the issue at the browser side of clearing the selected radio button however when the values is submitted back to the server, it has the last "default / selected" option as selected.

What are the recommendations?

@foxbit19
Copy link

foxbit19 commented Oct 9, 2020

Same issue here.
unselectAll doesn't work. Unselection for all options works only using the following lines:

$('.myselect').val('');
$('.myselect').multiselect('refresh');

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

No branches or pull requests

6 participants