SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery & Slimbox not playing along

    Hi I am using slimbox for image enlargement effects seen on this page which works great. I then wanted to use some jquery for scrolling to anchors in an FAQ section seen here.

    For some reason the jQuery won't work unless the slimbox javascript lines are removed from the head of the document.

    Any ideas...?

    Thanks

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's likely the libraries (mootools and jQuery) are conflicting. Given the ubiquity of the magic $ function this is not surprising.
    If this is the case it's a fairly easy fix to get jQuery operating in it's own container again:
    Code JavaScript:
    //Append to your jQuery source file
    var $j = jQuery.noConflict();

    You now use jQuery via $j:
    Code JavaScript:
    $j('#elementID').click(myFunction);

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great thanks, can't seem to get it working though. Where abouts in the jquery.js should I add the

    Code JavaScript:
    var $j = jQuery.noConflict();

    and would the code in my head that was

    Code JavaScript:
    <script type="text/javascript">
    			$(document).ready(function() {$("body").ScrollToAnchors(800,'bounceout')});
     
    	</script>

    Become..

    Code JavaScript:
    <script type="text/javascript">
    			$j(document).ready(function() {$j("body").ScrollToAnchors(800,'bounceout')});
     
    	</script>

    ?

  4. #4
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See here for more info: http://docs.jquery.com/Using_jQuery_...ther_Libraries

    I suggested adding that line at the end of your jQuery source file so that it'd automatically be done across your whole site. The JQ docs have it as part of a different script for illustrative purposes.

    And yes, you would have to modify your code as you have done above.

    If this doesn't work I may be off-track and something else is the problem.

  5. #5
    SitePoint Addict
    Join Date
    May 2006
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like thats cracked it sir! Thankyou


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •