【问题标题】:having issue with styling on popover show and hide弹出框显示和隐藏的样式有问题
【发布时间】:2016-02-19 04:27:11
【问题描述】:

html

<a class="popper btn" rel="popover" data-toggle="popover"><h3 class="gv layout">Layout Plan</h3> </a>
<div class="popper-content hide"> 
  <a href="pdf/layout1.pdf" target="_blank"><img src="images/layout1.jpg" class="btn"/></a> 
  <a href="pdf/layout2.pdf" target="_blank"><img src="images/layout2.jpg" class="btn"/></a> 
  <a href="pdf/layout3.pdf" target="_blank"><img src="images/layout3.jpg" class="btn"/></a> 
</div>

脚本:

$('.popper').popover({
placement: 'bottom',
container: 'body',
html: true,
content: function () {
    return $(this).next('.popper-content').html();
}
});

我希望这个在popover show上执行,在此先感谢任何人都可以在这里找到问题所在,

脚本:

$popover.on("show", function(e) {
    $("#transbg").css("padding-bottom","2600px");
});

下面的参考代码在小提琴中可以正常工作,但不适用于我的代码

   var $popover = $(".poper").popover({
    trigger: "click"
}).click(function(e) {
    e.$("#transbg").css("padding-bottom","260px"); 
});

$popover.on("hide", function(e) {
    $("#transbg").css("padding-bottom","50px");
});

【问题讨论】:

  • 您的 transbg id 好像丢失了
  • @ChristianEsperar 我在我的 html 代码中使用它来标记一个 div
  • 你能创建 jsfiddle 吗?所有相关代码都不适合你,jsfiddle.net

标签: javascript jquery twitter-bootstrap styling bootstrap-popover


【解决方案1】:

弹出框show事件语法不正确,可以试试下面的

HTML

<a class="poper btn" rel="popover" data-toggle="popover">
    <h3 class="gv layout">
        Layout Plan</h3>
</a>
<div class="popper-content hide">
    html
</div>

JS

var abc = $('.poper').popover({
    placement: 'bottom',
    container: 'body',
    trigger: 'hover',
    html: true,
    content: function () {
       return $(this).next('.popper-content').html();
    }
});

abc.on("shown.bs.popover", function (e) {
  console.log("popover shown");
});

abc.on("hidden.bs.popover", function (e) {
  console.log("popover hidden");
});

Fiddler

请参考this link关于引导弹出框

【讨论】:

  • 嗨@shu 我试过上面的代码它不会触发弹出窗口
  • hi 使用了 fiddle 中的这个 ref 代码,它在 fiddle 中可以正常工作,但在我的代码中却不行
  • @sasijj 你能检查一下类名是poper 还是popper,我也更新了答案。请检查
  • @sasijj 您正在使用哪个版本的引导程序
  • bootstrap v 3.3.1 它的 poper 确信它工作正常,但问题是我无法调用 popover 显示和隐藏的功能,即使我尝试了 bootstrap 事件侦听器样式显示.bs.popover
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-20
  • 2013-12-07
  • 2016-11-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多