How do I fix Lightbox2 problems using $.noConflict()?

家住魔仙堡 提交于 2019-12-24 19:12:08

问题


I've imported images to my site. I want to open these images with lightbox2. I've installed the lightbox2-drupalmodule and that works on my frontpage (www.chirowijkoersel.be), but it doesn't work on the pages where I imported images.

Lightbox does work with Opera. I've also noticed that the lightbox2-module adds a class to the images in Opera and on the frontpage with every other browser.

Links:

  • Images page
  • Frontpage

Edit: I've done some research, and I think the problem is caused by the multiple use of $. I can solve this by using $.noConflict(). But where do I need to put this?


回答1:


Wrap of you javascript, and use self invoking functions

(function($){

      /// Your page code here
      // Here you can use $ 
      // We are passing jquery as $ to this self invoking function.
})(jquery)



回答2:


it could be javascript conflicts ?




回答3:


You would put the $.noConflict() inside a script tag, right after you import jQuery. So if you have something like:

<script src="jQuery.js"></script>

already, you'd just do:

<script src="jQuery.js"></script>
<script>$.noConflict();</script>

Hope that helps.



来源:https://stackoverflow.com/questions/7042074/how-do-i-fix-lightbox2-problems-using-noconflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!