Search code examples
javascriptjquerytwitter-bootstrapstylingbootstrap-popover

having issue with styling on popover show and hide


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>

script:

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

i want this to execute on popover show, thanks in advance can any find what is the problem here,

script:

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

the below ref code works fine in fiddle but not with my code

   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");
});

Solution

  • The popover show event syntax is not correct,Can you try the following

    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

    Please refer this link regarding bootstrap popover