Cannot unselect by clicking selected when using dataAdapter
See original GitHub issueWhen using select2 with dataAdapter
, the selected option cannot be deselected by clicking it again on list.
If no dataAdapter
option is used, it works fine, option can be deselected by clicking it second time.
Here’s example with a bug I described, you can select any option and then try to deselect it by clicking it again. http://jsfiddle.net/o53fLqum/
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Select/Deselect checkbox does not work after selectAll ...
Use this mode. SelectAll handler : // note change event $('input[type="checkbox"][id="selectAll"]').change(function () { converter.
Read more >Unable to deselect in excel - Microsoft Community Hub
Yesterday when I selected multiple cells in a Microsoft Excel 2016 worksheet, I could hold CTRL key and deselect the cells I wanted...
Read more >Cannot deselect previously selected row in p-dataTable
In rc.4, the unselect fires with Ctrl+Click. Single click to unselect does not work even for single selection. Multiple selection works with ......
Read more >UITableView cannot deselect cells … | Apple Developer Forums
On click in the button that activates, tableView is in editing mode, with all cells selected. I could deselect and reselect at will....
Read more >Is it possible to unselect a cell in DataTable? - Dash Python
Remove or change hotpink selection from Datatable ... would be great if you could click on a cell/row/column to toggle active or selected....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Figured out the issue.
The
id
property on data objects must be a string or it won’t be able to match up with the<option>
that is created (since<option>.value
is always a string). This is why theelement
property isn’t getting set as expected on the data object which leads to pretty much the rest of the issues we were seeing. Setting theid
property to a string in the example jsfiddle solves these issues.https://select2.org/data-sources/formats#automatic-string-casting
I’m still leaving this open since Select2 should handle this case and automatically cast it, but it looks like something isn’t consistently doing that which is causing issues.
Sorry, ignore this attempt at a fix. I was testing it again using a hand-written
select2
example, and this time it isn’t working (theoption
elements do not exist), so I don’t think it’s valid.