简体   繁体   English

折叠div内的Bootstrap工具提示位置

[英]Bootstrap tooltip position inside collapsed div

Im creating a bootstrap accordion with collapsed panels to hold form input. 我创建了一个具有折叠面板的引导手风琴,以容纳表单输入。 Im trying to create a tooltip inside a collapsed panel above the input for validation output. 我正在尝试在输入上方的折叠面板内创建工具提示以进行验证输出。

  • Submit button is pressed it calls setTooltip function of each input. 按下提交按钮,它将调用每个输入的setTooltip函数。
  • Header panel (opens collapse content) then calls displayTooltip. 页眉面板(打开折叠内容),然后调用displayTooltip。

PROBLEM: When the panel is opened from collapse,all the tooltips are positioned around 50px above the input at (requires a collapse and open to repostion to correct place). 问题:当面板从合拢状态打开时,所有工具提示均位于输入上方50px处(需要合拢并打开以重新放置到正确的位置)。

Can anyone suggest a method for refreshing the tooltip that is inside the collapsed div or somehow resetting its position to correct place above input? 谁能建议一种刷新折叠div内工具提示的方法,或者以某种方式将其位置重置为输入上方的正确位置?

EDIT- The placement is correct when submitting and calling setTooltip and the div is not collapsed. 编辑-提交和调用setTooltip时放置位置正确,并且div不折叠。

function setTooltip(obj, value, pos) {
    options = {placement: pos, trigger: 'manual'}

    $(obj).tooltip(options)
            .attr('data-original-title', value)
            .tooltip('fixTitle');
}

function displayTooltip(obj) {
    options = {placement: "top", trigger: 'manual'}

    $(obj).tooltip(options).tooltip('show');
}

I have created an example JSFiddle where I use bootstrap tooltip in combination with a accordion object. 我创建了一个示例JSFiddle,在其中结合使用了bootstrap工具提示和手风琴对象。

Is this what you want? 这是你想要的吗? http://jsfiddle.net/dheLm7u6/ http://jsfiddle.net/dheLm7u6/

JQUERY: JQUERY:

$(function () {
    $('#buttonid').click(function()
    {
        if( !$('.test1').val() ) {
              $('[data-toggle="tooltip"]').tooltip('show');
        }
    });

});

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

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