How to prevent the popover div for hiding on clicking inside it for twitter bootstrap “dismissible popover”(data-trigger=“focus”)?

前端 未结 4 1339
时光说笑
时光说笑 2021-02-20 07:01

I have a a dismissible popover(data-trigger=\"focus\") with a text box inside it. But as soon as I click inside the text box to type it dissappear because of the \"data-trigger=

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 07:29

    This code works for me, you can dismiss the popover upon any condition by calling preventDefault() method.

    var closePopOver=true;
        $('[data-toggle="popover"]').popover({
            html: true,
            title: '',
            content: function () {
                return 'Your Html Here';
            }
        }).on('hide.bs.popover', function (hideEvent) {
            if (!closePopOver) {
                hideEvent.preventDefault();
            }
        });
    

提交回复
热议问题