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

title attribute is not working when you don't use multiple #738

Closed
bboerendans opened this issue Sep 16, 2014 · 11 comments
Closed

title attribute is not working when you don't use multiple #738

bboerendans opened this issue Sep 16, 2014 · 11 comments

Comments

@bboerendans
Copy link

It would be very useful if we can use the title attribute also with a default select picker, like:

<select class="selectpicker" title='Choose one of the following...'>

For now its only working when you specify multiple.

@Robelind
Copy link

Totally agree.
It is a total deal breaker to not be able to have a non-multiple select picker with nothing selected initially.
If on top of that you could set a title, so much the better.

@truckingsim
Copy link
Contributor

If you want a placeholder option just add

<option data-hidden="true">Choose one of the following</option>

as the first option and bootstrap-select will auto select that as the placeholder when nothing is selected.

@parano
Copy link

parano commented Sep 26, 2014

@truckingsim That won't work if you also made that selection data-live-search. I'm wondering why is it designed like this in the first place?

@nobreferreira
Copy link

+1

@cossssmin
Copy link

<option data-hidden="true" value="">Choose one...</option>

This I think is better, because otherwise your select will have by default the value of the hidden options' text.

Still a hackish way though, it makes no sense to have an empty option as a label, when one could ideally use a title="" attribute just as with the multiple selects...

@caseyjhol
Copy link
Member

@hellocosmin I guess I'm not sure what the fix is here? A regular select has to have at least one option selected at all times. I suppose setting the title attribute could just automatically insert

<option data-hidden="true" value="">Choose one...</option>

@nickbouton
Copy link

@caseyjhol Tested against 0351bd8 and still having to use the hidden option hack manually... setting the data-title="" attribute or passing title as an argument to .selectpicker() still doesn't seem to be respected in 1.7.0 RC1. I notice that if you set either, a hidden option is added to the top of the select, but the option's text node is empty.

@caseyjhol
Copy link
Member

Hrmm...it's working for me (Chrome 42, Windows 8.1). Can you provide me with a jsfiddle? The option's text node is empty on purpose. render() already checks to see if the selected option is empty, and if so, sets the title accordingly.

caseyjhol added a commit that referenced this issue May 7, 2015
Also fixes an issue when actionsBox is set on a non-multiple select.
Fixes #1017. Add commentary explaining liObj.
@caseyjhol
Copy link
Member

@nickbouton Give it a shot now using the latest version from master. I was able to reproduce it if the select had a lot of options, but it was working fine on a select with ~20 options.

@nickbouton
Copy link

@caseyjhol Scratch my previous comment, I dumped a cut-down version of what I had into JSfiddle and it looks to be working fine. Might be another library version causing issues or conflicting with something, I'll try and track it down here. Thanks for your help.

@wreardan
Copy link

I experienced this problem as well. I attempted to update the bootstrap-select code to apply this fix. However, this significantly changed the styling inside our application. I fixed the problem by applying the above fix
data-hidden="true"

avantika-gupta-jtg pushed a commit to JoshLabs/bootstrap-select that referenced this issue May 14, 2020
A blank option is prepended to the select, which is then selected by
default. This allows the title to be shown when the select is initially
loaded and "no" options are selected yet. Close snapappointments#888. Close snapappointments#738.
avantika-gupta-jtg pushed a commit to JoshLabs/bootstrap-select that referenced this issue May 14, 2020
Also fixes an issue when actionsBox is set on a non-multiple select.
Fixes snapappointments#1017. Add commentary explaining liObj.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants