简体   繁体   English

为什么加载$(document.ready(function())时.click不起作用?

[英]Why doesn't .click work when $(document.ready(function() is loaded?

I have a page where this code is loaded: 我有一个加载此代码的页面:

$(document).ready(function(){
      console.log('document ready');
      $('[data-toggle="popover"]').popover({
        trigger : 'manual',
        placement : 'right'
      }).click(function(e) {

        console.log('click');

In my console i see 'document read', so it is loaded. 在我的控制台中,我看到“文档已读”,因此已加载。 But when i click on the data-toggle, it doesn't work. 但是,当我单击数据切换时,它不起作用。 Only if i reload the whole page with F5, the datta-toggle works. 只有当我用F5重新加载整个页面时,datta-toggle才起作用。 Someone know why? 有人知道为什么吗?

Thanks. 谢谢。

Found the answer: 找到了答案:

Had my html page within an ui-view, this prevents the jquery .click to be loaded when entering the page, only after F5 reload it will load the .click event. 如果我的html页面位于ui视图中,则可以防止进入页面时加载.click jQuery,只有在F5重新加载后,它才会加载.click事件。

Now the page is loaded outside the ui-view and it works. 现在,该页面已加载到ui视图之外,并且可以正常工作。

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

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