gfranko / jquery.selectBoxIt.js

A jQuery Select Box Plugin for Mobile, Tablet, and Desktop
http://www.selectboxit.com
MIT License
852 stars 301 forks source link

data-selectedtext doesn't work on mobile #386

Open nileLivingston opened 6 years ago

nileLivingston commented 6 years ago

First off, thanks for the fantastic plugin. I get a lot of use out of it, and I'm happy to see it so well-supported.

I noticed that the data-selectedtext attribute doesn't work on mobile. This is the case for the official example, so I'm confident the bug isn't an artifact of my implementation.

The issue appears to originate in the _updateMobileText function, on line 2945:

self._setText(self.dropdownText, currentText);

which doesn't contain any references to selectedText. I fixed it locally by first defining currentDataSelectedText inside of _updateMobileText, as it is elsewhere in the source code:

currentDataSelectedText = currentOption.attr("data-selectedtext");

And then by replacing the erroneous line 2945 with the following:

self._setText(self.dropdownText, currentDataSelectedText || currentText);

Thanks again!

Rik-Patel commented 5 years ago

Hi, Are you able to share your JS file code fix? I am running into the same issue.

nileLivingston commented 5 years ago

Sure thing; you'll find my modified code attached.

(Apologies for the file extension, GitHub won't allow me to attach a .js file)

jquery.selectBoxIt.min.js.txt

Rik-Patel commented 5 years ago

Thanks! Appreciate it. I have verified this fix works in mobile.