SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Location
    Berlin
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery Slider doesn't work anymore

    Hey,

    I built a site with a slider which already worked for a while but it doesn't anymore. I really regret that I didn't wrote something like a change log or a history of the file versions or something. So I changed the background pictures of the slider and some other css stuff with the caption and suddenly the slider didn't work anymore. The pictures appear, but they don't slide and those buttons for switching the pictures don't come up anymore.

    I can't remember what I changed before and I don't know whats wrong now, I checked all the linkers to the jQuery files but could not find the mistake.
    The project is uploaded to my webspace on http://www.phermann.tk/gera .

    I hope you can help me. (I am totally expecting a dump mistake by the way.)
    Thank you, Paul.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,321
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Try moving this bit in red:

    Code:
    <body>
            <script>
                $('.slider').glide();
            </script>
    to the bottom of the page, just before the </body> tag:

    Code:
            <script>
                $('.slider').glide();
            </script>
    </body>
    At the moment, the script is looking for the .slider div before it has loaded, so let it load first and then call on it with JS.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Location
    Berlin
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great, that solves the problem. Know as you wrote it, I actually don't understand why the jQuery isn't like that instead:

    <script>
    $(document).ready(function() {
    $('.slider').glide();
    )};
    </script>

    The position of the code would be unimportant then.

    Thanks!

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    That should still be at the bottom of the page for it to work right. It waits for the document to be ready before initialising.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,321
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by LamboLight View Post
    I actually don't understand why the jQuery isn't like that instead:

    Code:
    <script>
                $(document).ready(function() {
                    $('.slider').glide();
                )};
            </script>
    Yes, that's commonly done with jQuery if you don't place it at the end of the file. (document).ready just makes sure that the document has loaded before the script operates. I had two choices—to tell you to place the code at the bottom OR to wrap document.ready around it. But I chose the first option as it's a good idea anyway.


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
  •