简体   繁体   English

如何从Bootstrap 4配置Popper.JS

[英]How to configure Popper.JS from Bootstrap 4

I'm using split.js to split the screen into two parts. 我正在使用split.js将屏幕分为两部分。 On the right part, there are few input fields having Bootstrap tooltip on focus. 在右侧,很少有输入字段具有Bootstrap工具提示。

As the width of the container isn't wide enough on the right part, Bootstrap tooltips are not displayed on the left, as they should, over the gutter, but on the right. 由于容器的宽度在右侧不够宽,因此Bootstrap工具提示不会显示在左侧,而是应该显示在装订线上方,而是显示在右侧。

To deal with it I had to import bootstrap.min.js in my project and modify the following lines : 为了处理它,我必须在我的项目中导入bootstrap.min.js并修改以下几行:

preventOverflow: {
    boundariesElement: this.config.boundary
}

by 通过

preventOverflow: {
    enabled: false,
    boundariesElement: this.config.boundary
}

The structure of input fields of the right part is like this. 右侧输入字段的结构是这样的。

<div id="leftContainer"></div>
<div id="rightContainer"></div>
    <table>
        <tr>
            <td>
                <label>
                      <div>someText</div>
                      <input type="text"
                             size="2"
                             rel="tooltip"
                             data-toggle="tooltip"
                             data-trigger="focus"
                             data-placement="left"
                             data-html="true"
                             data-title="someTitle"
                             value="someValue"
                             name="someName" />
                </label> etc. ...

And they are initialized like this 他们像这样初始化

$(function() { $('[rel="tooltip"]').tooltip({ trigger:'focus', placement: 'left' }); });

My question is: instead of importing bootstrap.min.js in my project and modify the code to disable preventOverflow from PopperJS implementation in Bootstrap, is there a way to configure PopperJS in Bootstrap properly (like when I'm initializing tooltips, instead of modifying Bootstrap JS)? 我的问题是:不是在我的项目中导入bootstrap.min.js并修改代码以禁用Bootstrap中PopperJS实现的preventOverflow,有没有一种方法可以在Bootstrap中正确配置PopperJS(例如,当我初始化工具提示时,而不是修改Bootstrap JS)?

You can just set the default "boundary" to the window. 您可以将默认“边界”设置为窗口。 Then it will be able to overflow out of its parent element. 然后它将能够溢出其父元素。

Just add this line of JS after you include bootstrap: 包含引导程序后,只需添加以下这行JS:

$.fn.tooltip.Constructor.Default.boundary = "window";
$.fn.dropdown.Constructor.Default.boundary = "window";

(it took quite some time to find the documentation on customizing these config settings, I could only find this super short explanation here ) (花了相当长的时间才能找到有关自定义这些配置设置的文档,我只能在这里找到这个简短的说明)

Testing around a little bit, you can also just pass an invalid string, like "none". 进行一点测试,您也可以只传递一个无效的字符串,例如“ none”。 (only "window", "viewport", and "scrollParent" (the default) are supported ) (唯一的“窗口”,“视口”,和“scrollParent”(默认) 的支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM