我在我的自定义jquery代码中使用了popover bootstrap,我想在popover('disable')之后像.popover('enable')一样激活它
我的代码如下:
$('#edit-mode').on('click',function(){
$(this).toggleClass('edit-on');
if($(this).hasClass('edit-on')){
$(this).css('color','#d9534f');
//to disable link
$('.alink').click(function(){
return false;
});
//$('.alink').popover('enable');
//popover a link
$('.alink').popover({
animation: true,
html : true,
trigger: "click",
placement: 'top',
container: 'body',
stayOnHover: true,
selector: this,
delay: {show: 100,hide: 100},
content: function() {
return $('#popover_content_wrapper').html();
}
});
}
else{
$(this).css('color','#3276b1');
//to enable link
$('.alink').click(function(e){
window.location.href = $(this).attr('href');
});
$('.alink').popover('hide');
//disable popover
$('.alink').popover('disable');
}
});发布于 2016-02-17 02:41:57
我已经找到了一种解决方法来实现这一点。
要禁用它,请执行以下操作:
$(".popover").remove();
$('.alink').popover('destroy');要启用它,只需使用popover()再次初始化它
$('.alink').popover({
animation: true,
html : true,
trigger: "click",
placement: 'top',
container: 'body',
stayOnHover: true,
selector: this,
delay: {show: 100,hide: 100},
content: function() {
return $('#popover_content_wrapper').html();
}
});发布于 2013-12-04 04:16:32
我为我的应用程序解决了这个问题,将禁用的元素包装在div中,然后将popover代码放在div本身上。以下是一个Rails应用程序的示例:
<div rel="popover" class="popover-top" data-content="content goes here" data-title="title goes here" data-trigger="hover" data-original-title="" title="">
<input class="line_item_quantity" disabled="disabled" id="order_line_items_attributes_0_quantity" min="0" name="order[line_items_attributes][0][quantity]" size="5" type="number" value="10">
</div>https://stackoverflow.com/questions/20283308
复制相似问题