August 2, 201214 yr Hey guys, Pulling my hair out at this one - I've got a slideshow on my site which also uses jquery mobile: http://palmercreative.co.uk/m/ It seems to display the slideshow as if there's no jquery first time, then when you refresh it's ok? Is it something to do with the way I'm loading the jquery in? Is there some sort of no conflict thing I need? The head looks like: <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Canal holiday - Find the Best Canal Holiday of superior quality from College Cruisers </title> <link rel="stylesheet" href="themes/style.min.css" /> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile.structure-1.1.0.min.css" /> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script> <script src="js/responsiveslides.min.js"></script> <script> $(function () { // Slideshow 1 $("#slider1").responsiveSlides({ maxwidth: 800, speed: 800 }); }); </script> </head> Many Thanks, Chris Edited August 2, 201214 yr by Crispy
August 2, 201214 yr At first glance it sounds like the function is being run before jquery or some other resource has been fully loaded. Wrap the function in "$(document).ready(function () { });" like this <script> $(document).ready(function () { $(function () { // Slideshow 1 $("#slider1").responsiveSlides({ maxwidth: 800, speed: 800 }); }); }); </script>
August 2, 201214 yr Author Hmmm, that didn't seem to fix it, tried it on this page: http://palmercreative.co.uk/m/oxford-banbury.html
August 2, 201214 yr The script block that calls the responsiveSlider function appears not to be executed. There is a block of code at the end of the page that is throwing a javascript error, it's the very last script block on the page. Could you try removing that in case the error is interfering with executing your code.
August 2, 201214 yr $(function () { Is exactly the same as: $(document).ready(function () { It's just a shorthand way of writing it. The slider is working fine for me though. Edited August 2, 201214 yr by Spitfire
August 2, 201214 yr Well, you learn something new every day! Shows how rusty my front end skills are, I think I've spent too much time as a server side developer. Out of interest Spitfire what browser are you using? I can't get the slider to work unless I remove the script block at the end of the document. $(function () { Is exactly the same as: $(document).ready(function () { It's just a shorthand way of writing it. The slider is working fine for me though.
August 3, 201214 yr Author Hmm, Have I messed something up? Even with the bottom block commented out it's still not working for me: http://palmercreative.co.uk/m/oxford-banbury.html
August 3, 201214 yr I'm not sure if this will fix your problem, but when I inspected your page, there was an extra line of closing curly brackets and parenthesis and it's throwing an error. Edit: This is on the latest link (the post prior to mine) you've provided. Edited August 3, 201214 yr by Pete Prosper
Create an account or sign in to comment