0

im using lightbox.js it needs prototype.js and i need to use jquery.js. Now both of these libraries dont work together. Can someone explain how to do noconflict?

The manual on jquery website said i needed to include the prototype.js right after i called noconflict within the script tags, im not sure how to do this. these are the two files that need prototype

<script type="text/javascript" src="includes/jquery/lightbox/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="includes/jquery/lightbox/js/lightbox.js"></script>
4
  • 4
    If at all possible, do yourself the favour and use only one of the libraries. There are many lightbox alternatives for jQuery. Commented Feb 18, 2012 at 18:29
  • When making a JavaScript question, it's usually a good idea to create a jsFiddle test case. Commented Feb 18, 2012 at 18:34
  • @Inerdial: Generally that's true, but not for this kind of question. Commented Feb 18, 2012 at 18:44
  • Because the fact that he's mixing jQuery and prototype explains enough. Commented Feb 19, 2012 at 20:16

2 Answers 2

1

The answer is simply: Use a jQuery-based lightbox alternative. Colorbox is pretty good for example.

However, noConflict is pretty easy, too:

After including jQuery, run this code: jQuery.noConflict();. To keep using $ in your code, wrap it with the following:

(function($) {
    // your code
})(jQuery);
Sign up to request clarification or add additional context in comments.

Comments

0

I agree with everyone elese. If jQuery is a requirement, then switch to a jQuery based light box. There are a TON of them.

That said this is waht the documentation means:

<!-- inc. jquery and call noConflict -->
<script type="text/javascript" src="includes/jquery/jquery.js"></script>
<script type="text/javascript">
  jQuery.noConflict();
</script>

<!-- inc. inc. prototype stuff -->
<script type="text/javascript" src="includes/jquery/lightbox/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="includes/jquery/lightbox/js/lightbox.js"></script>

1 Comment

i switched to shadowbox which is jquery plugin :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.