2015-10-26 157 views

回答

0

這是我自己的問題的解決方案。

var idpop = []; //Creating an array to store the id 
//Since that when you create a popover using Krajee Popoover X plugin, 
//you always add id's to it. 
//By default, only one popover will displayed at a time. 
$('.popover').on('shown.bs.modal', function() { 
    //Get the id of the popover that is currently displayed 
    idpop.push($(this).attr('id')); //Add the id to the Array 
}); 
$('.popover').on('hidden.bs.modal', function() { 
    //Empty the array when the popover is dismissed 
    idpop = []; 
}); 
$('html').on('click', function(e) { 
    //when click outside the popover then dismiss the popover 
    if ($(e.target).closest('.popover').length == 0) { 
    $('#' + idpop[0]).popoverX('hide'); 
    } 
}); 
相關問題