views:

716

answers:

1

(CrossSlide)

(LightBox)

This is my header:

<script type="text/javascript" src="<?php echo ROOT.'sources/js/jquery.js'; ?>"></script>
<script type="text/javascript" src="<?php echo ROOT.'sources/js/contentSlider/jquery.cross-slide.js'; ?>"></script>
<link rel="stylesheet" href="<?php echo ROOT.'sources/css/lightbox.css'; ?>" type="text/css" media="screen" />
<script type="text/javascript" src="<?php echo ROOT.'sources/js/lightbox/prototype.js'; ?>"></script>
<script type="text/javascript" src="<?php echo ROOT.'sources/js/lightbox/scriptaculous.js?load=effects,builder'; ?>"></script>
<script type="text/javascript" src="<?php echo ROOT.'sources/js/lightbox/lightbox.js'; ?>"></script>

This is my body:

 <script type="text/javascript">
 $(function() {
    $('#imgHold').crossSlide({
      sleep: 3,
      fade: .5
    }, [
      { src: 'images/featured/ftcont_img1.png' },
      { src: 'images/featured/ftcont_img2.png' },
      { src: 'images/featured/ftcont_img3.png' },
      { src: 'images/featured/ftcont_img4.png' }
    ]);
 });
 </script>
 <div id="ftIMG"><div id="imgHold">Loading...</div></div>

I don't have anything using the lightbox script on this page. But I want the keep the script in the header so in PHP I only have to call up 1 header. The LightBox "manual" said to add "initLightbox(); to the onload attribute on the body tag, so I did that and nothing changed. Now I also read somewhere else about a (jQuery.no-conflict), im wondering if this would be the way to proceed. Or if there is another way to fix this problems.

Also, if I want to use (ThickBox3.1) on the same page with everything else. Would it be possible, and how to do so exactly?

Also, sorry guys about not posting them up as links, apparently new users are not allowed to post up more than 1 link.

A: 

Try changing your code snippet to the following:

jQuery(function() {
    jQuery('#imgHold').crossSlide({
      sleep: 3,
      fade: .5
    }, [
      { src: 'images/featured/ftcont_img1.png' },
      { src: 'images/featured/ftcont_img2.png' },
      { src: 'images/featured/ftcont_img3.png' },
      { src: 'images/featured/ftcont_img4.png' }
    ]);
 });

This might work as long as there are no other conflicts on the page.

See this article on docs.jquery.com for how to use jQuery with other libraries such as prototype and scriptaculous, both of which you're making use of in your example.

jammus
thank you!that fixed exactly what I was looking for. But as I was testing out the lightbox script, it wouldn't load any of the function buttons (next, prev, close). im not sure if it was a problem on my end, that I messed up the links, so I'll will take a look into that, but thanks for helping me get crossSlide working.
imHavoc
No worries. Your other problem is related to the image paths. You'll need to edit lightbox.js to update these -they're pretty near the top.
jammus
I fixed the images paths and it is still not working. any ideas?
imHavoc
You're 100% sure they're correct? If you right click and 'inspect element' (using Chrome or Firebug in Firefox) over where the close button should be and then look at the img tag. Does the src point to where you have the image on the server?
jammus
Can you post a link to your example?
jammus