Search code examples
javascripthtmlcsstwitter-bootstrapbootstrap-material-design

Bootstrap material design - Ripples not showing in popover


I am using bootstrap material design: https://fezvrasta.github.io/bootstrap-material-design/bootstrap-elements.html

This includes a neat ripple effect when pushing buttons, and this works everywhere in my page except in a popover div that has display:none in the html but is made visible to the user with javascript.

HTML:

<a href="#" class="pop" data-id="#popover_div1" data-container="body" data-placement="top" title="Popover title">Click to open popover</a>
<div id="popover_div1" style="display: none">
    <div>
        <img class="img-rounded" src="img/temp.png" alt="temp" height="25" width="25"/>
        This is your div content
    </div>
    <div>
        <div class="btn-group">
            <a href="javascript:void(0)" class="btn btn-default">5</a>
            <a href="javascript:void(0)" class="btn btn-default">6</a>
            <a href="javascript:void(0)" class="btn btn-default">7</a>
        </div>
    </div>
</div>

JS:

$(".pop").popover({
    trigger: "manual", 
    html: true, 
    animation:false, 
    content: function() {
        return $($(this).attr('data-id')).html();
    }
}).on("mouseenter", function () {
    var _this = this;
    $(this).popover("show");
    $(".popover").on("mouseleave", function () {
        $(_this).popover('hide');
    });
}).on("mouseleave", function () {
    var _this = this;
    setTimeout(function () {
        if (!$(".popover:hover").length) {
            $(_this).popover("hide");
        }
    }, 200);
});

If I take out style="display:none", the ripple effect works, but including it makes the ripples effect not work for the buttons inside the div, really strange. Is there any way for me to keep display:none (because that way the popover works just like I want it to), but still have the ripples effect on the buttons in the div?


Solution

  • Try calling $.material.ripples() after showing the popup.