首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我想在禁用popover引导后启用它

我想在禁用popover引导后启用它
EN

Stack Overflow用户
提问于 2013-11-29 18:14:08
回答 2查看 2K关注 0票数 0

我在我的自定义jquery代码中使用了popover bootstrap,我想在popover('disable')之后像.popover('enable')一样激活它

我的代码如下:

代码语言:javascript
复制
$('#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');
    }                                               
});
EN

回答 2

Stack Overflow用户

发布于 2016-02-17 02:41:57

我已经找到了一种解决方法来实现这一点。

要禁用它,请执行以下操作:

代码语言:javascript
复制
$(".popover").remove();   
$('.alink').popover('destroy');

要启用它,只需使用popover()再次初始化它

代码语言:javascript
复制
$('.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();
            }
        });
票数 1
EN

Stack Overflow用户

发布于 2013-12-04 04:16:32

我为我的应用程序解决了这个问题,将禁用的元素包装在div中,然后将popover代码放在div本身上。以下是一个Rails应用程序的示例:

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20283308

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档