3

I'm using the jquery UI to slide a div up on hover. It works fine on its own but I'm having trouble with it working when this <script src="http://www.google.com/jsapi" type="text/javascript"></script> is also installed, (I'm using this to .load some content elsewhere on the page) If I remove either script they work fine, but together the jquery UI stops working.

These are the scripts that I'm using - any idea of the best way around this? Thanks in advance.

<script src="http://www.google.com/jsapi" type="text/javascript"></script>

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
Mike Woodhouse
  • 51,832
  • 12
  • 88
  • 127
sam
  • 9,486
  • 36
  • 109
  • 160
  • are you loading these in the head, or elsewhere? where are you loading the script that calls jquery ui? what errors are you getting? – newtron May 02 '12 at 14:26
  • Hi, im loading them in the head, the errors im getting are just that on hover the div wont appear, but if i remove it works fine. (but without that the .load wont work). the site in question is new.pudle.co.uk – sam May 02 '12 at 14:31
  • I haven't looked at the site yet, but you might be making the jQuery UI calls before jQuery UI has finished loading. Loading the Google stuff or not might make the difference in timing. – newtron May 02 '12 at 14:37

1 Answers1

6

When you use Google jsapi, you must load jquery and jquery UI using the load method only :

    <script type="text/javascript">
      google.load("search", "1");
      google.load("jquery", "1.4.2");
      google.load("jqueryui", "1.7.2");
    </script>

(from https://developers.google.com/loader/ )

That's the whole point : you don't need to include (and serve) the jquery files yourself as you're using Google API (and servers).

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
  • works great, thanks allot ! is it still necessary to provide fallback jquery hosted on my server ? – sam May 02 '12 at 14:43
  • No. It wouldn't work. And when your problem is only Google server not responding, you're doing very fine ! Don't forget those files are cached by the browser, and as they're used by many sites they're likely to remain in the cache. – Denys Séguret May 02 '12 at 14:45