28

I'm using Bootstrap Select to style some select fields inside an accordion. Bootstrap select has a feature where it will make your dropdown dropup if it is near the bottom of the screen.

In this case I do not want it to drop up but I can't find where to disable this.

Bootstrap select: https://developer.snapappointments.com/bootstrap-select/

3 Answers 3

53

Options can be passed via JavaScript or data attributes:

$('.selectpicker').selectpicker({
    dropupAuto: false
});

or

<select class="selectpicker" data-dropup-auto="false">
    <option>Mustard</option>
    <option>Ketchup</option>
    <option>Relish</option>
</select>

You can also set this globally:

$.fn.selectpicker.Constructor.DEFAULTS.dropupAuto = false;
Sign up to request clarification or add additional context in comments.

7 Comments

Except you don't want quotes around 'false'. It needs to be boolean. :)
I tried all these and still cannot stop it from dropping up and when it drops up it is hidden behind the navbar.
@GrahamHesketh What version are you using?
v1.13.0 I need it to be compatible with bootstrap 4
Where is camelCase in JS, there is dash and lowercase in data- attribute. So dropupAuto became data-dropup-auto, selectedTextFormat is data-selected-text-format... etc Good to know :) See all options in documentation.
|
2

This setting can be changed in the bootstrap-select.js file by editing the dropupAuto option to:

dropupAuto: false,

Comments

-1

You can use this to disable the picker. $('.selectpicker').prop('disabled', true);

1 Comment

I think you misunderstood the question. The OP wants to stop the Bootstrap Select control from dropping upwards as opposed to downwards so that it always drops down, and never up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.