Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem with Jquery Loading in? [Live Example]

Featured Replies

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 by Crispy

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>

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.

   $(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 by Spitfire

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.

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 by Pete Prosper

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.