How do I make the backdrop appear when the popover is displayed, and disappear when the popover is closed?
$(function(){
var content = '<button class="btn btn-sm btn-default" onclick="location.href=\'/billing/\'">Pay Now</button> <button class="btn btn-sm btn-default " onclick="$(".btn-upgrade-premium").popover("hide");">Activation Code</button>';
$('.btn-upgrade-premium').popover({animation:true, content:content, html:true, placement: 'bottom'});
$('.btn-upgrade-premium').click(function(){
$('#backdrop').toggleClass('modal-backdrop in');
});
});
.btn-upgrade-premium
{
text-shadow: 0px 1px 0px #FFF;
background-image: linear-gradient(to bottom, #FFEEBE 0%, #fec215 100%);
background-repeat: repeat-x;
border-color: #fec215;
z-index: 1052;
}
.btn-upgrade-premium:active
{
background-color: #fec215;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<button type="button" class="btn btn-upgrade-premium btn-sm" style="margin-top:11px; padding-bottom:4px; padding-top:4px;" data-container="body" data-trigger="focus" data-placement="left">
Upgrade to Premium
</button>
<div id="backdrop"></div>
IMPORTANT:
The issue is that the backdrop does not disappear even after toggling the class.