简体   繁体   English

引导程序弹出窗口不允许DOM访问。 该怎么办?

[英]Bootstrap popovers don't allow DOM access. What to do?

I have problems with Bootstrap (3.3.4) popovers. 我在Bootstrap(3.3.4)弹出式窗口中遇到问题。 My html code for the popover is in the data-html tag, which also contains a class link_click. 我的弹出窗口html代码位于data-html标记中,该标记还包含一个类link_click。 The jQuery click function for this class doesn't work. 此类的jQuery click函数不起作用。 Why is jQuery not seeing this link_click class from data-content field of the popover? 为什么jQuery在弹出窗口的data-content字段中看不到这个link_click类? What to change? 要改变什么?

popover = '<a href="javascript:void(0)" data-toggle="popover" data-placement="bottom" data-html="true" data-content="<a href=\'javascript:void(0)\' class=\'link_click\'>Popover Link not working</a><br>">Main-Objekt</a>';

$('#popover_test').html( popover );

$('[data-toggle="popover"]').popover({ trigger:"manual", animation:false})
.on("mouseenter", function () {
var _this = this;
$(this).popover("show");
$(".popover").on("mouseleave", function () {
    $(_this).popover('hide');
});})
.on("mouseleave", function () {
var _this = this;
setTimeout(function () {
    if (!$(".popover:hover").length) {
        $(_this).popover("hide");
    }
}, 100);
}); 

$('.link_click').click( function(){
    alert('Click success!');
}); 

Thanks 谢谢

Michael 麦可

Event delegation for dynamic content: 动态内容的事件委托:

$('#popover_test').on('click', '.link_click', function(){
    alert('Click success!');
}); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM