dbrekalo / fastselect

Fastselect is lightweight browser plugin for enhanced select elements based on jQuery. Enables fast and sensible UI upgrade of select element with features like option searching and remote dataset loading.
http://dbrekalo.github.io/fastselect/
MIT License
108 stars 87 forks source link

fastselect does not always deselect! #17

Open Fenno1974 opened 7 years ago

Fenno1974 commented 7 years ago

With the multi-select option, the behavior I am expecting is when an item is deleted (by clicking on the cross), it is also deselected from the drop down. In some cases, this is occurring ok, but in other cases the item remains selected. (see attached).

This is the one that does not work: example that does not work

This one does work: example that does work

I have compared the html and cannot see any differences, so it is a mystery why the deselect is not working in some cases.

I am using MVC5 ASP.NET

Please help....

Fenno1974 commented 7 years ago

Problem solved! I did some debugging of the fastselect.js file to find that this problem only occurred when the value field of my options was an integer. If it was a Guid or string, it was perfectly ok.

By modifying line 608 of fastselect.js to be a == comparison, rather than === solved the problem! capture

xAlstrat commented 7 years ago

Hi Fenno ! Thanks you so much ! I came here to solve the same problem, you saved me a lot of time.

DiMono commented 6 years ago

This code is now located on line 1171 in the current version. There is a similar comparison on line 938, presumably for adding the value rather than removing it, but it probably doesn't need to be changed.