twitter-bootstrap 使用 Bootstrap Select 禁用下拉功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19934518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 19:10:44  来源:igfitidea点击:

Disable dropup feature using Bootstrap Select

twitter-bootstrapselectbootstrap-select

提问by Anthony_Z

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.

我正在使用 Bootstrap Select 来设置手风琴内的一些选择字段的样式。Bootstrap select 有一个功能,如果它靠近屏幕底部,它将使您的下拉菜单成为下拉菜单。

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/

引导选择:https: //developer.snapappointments.com/bootstrap-select/

回答by caseyjhol

Options can be passed via JavaScript or data attributes:

选项可以通过 JavaScript 或数据属性传递:

$('.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;

回答by Anthony_Z

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

可以通过编辑 dropupAuto 选项在 bootstrap-select.js 文件中更改此设置:

dropupAuto: false,

dropupAuto:假,

回答by i k o n g

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

您可以使用它来禁用选择器。$('.selectpicker').prop('disabled', true);