[英]Popper.js not initializing on document load
When I try to initialize Popper.js like below, nothing happens. 当我尝试像下面那样初始化Popper.js时,什么都没有发生。
$().ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
However if I apply the same code to a button, it magically works as soon as it is pressed. 但是,如果我将相同的代码应用于按钮,则一旦按下按钮,它就会神奇地工作。
$('#randomButton').click(function(){
$('[data-toggle="tooltip"]').tooltip();
});
How can I fix this problem? 我该如何解决这个问题? My imports already are in the order suggested in this post.
我的导入已经按照这篇文章中建议的顺序进行了。
Adding this code to my main.js file fixed it: 将此代码添加到我的main.js文件中可以解决此问题:
setTimeout(function(){
$('[data-toggle="tooltip"]').tooltip();
}, 500);
I guess what happened is that I tried to initialize the tooltips before the elements with the tooltips could even be loaded via ajax. 我猜发生了什么事,我试图在甚至可以通过Ajax加载带有工具提示的元素之前初始化工具提示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.