2

I am getting the error : $(".scrollable").scrollable is not a function when I attempt to use the scrollable

<html>
<head>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
</head>
<body>
<script>
$(function() {
  // initialize scrollable with mousewheel support
  $(".scrollable").scrollable({ vertical: true, mousewheel: true });
});
</script>
</body>
</html>

Can anyone see what is causing this?

[Edit]

After Mark Hildreth pointed out that the library I was using already bundles jQuery, I removed my Google jQuery CDN reference (not shown above), and then I got the '$ is not a function' error.

I knew then that jQuery was clashing with flowplay, so I updated my pages to use

jQuery.noConflict();
jQuery(document).ready(function()){
   // jQuery('#foo) .... etc
});

This is mildly annoying, as I have to change the script in my existing pages to use jQuery instead of $.

Is there anyway I can continue to use $, or do I HAVE to use jQuery ?

oompahloompah
  • 9,087
  • 19
  • 62
  • 90

4 Answers4

1
// you don't have to use jQuery(document).ready(function()){});
// or noConflict

$ = null; // doean't matter here what happens to $

// just wrap your jQuery code passing in jQuery...
(function ($) {
    //write jQuery here...
    $(".scrollable").scrollable({
        vertical: true,
        mousewheel: true
    });
})(jQuery);
Justin Obney
  • 1,078
  • 3
  • 13
  • 25
1

If you are including http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js in your code then you need to write jQuery.noConflict();

Mihir Bhatt
  • 3,019
  • 2
  • 37
  • 41
0

Use

    var $j=jQuery.noConflict();

Since javascript also uses $ symbol, conflicts arise. Then you can write the code as follows

    $j(document).ready(function()){
    // jQuery('#foo) .... etc
    });
Chandrashekar
  • 61
  • 1
  • 5
0

Looking at your code, I think that you are missing the jQuery library. You can include it from google cdn.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>

source: http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/

pedrofs
  • 612
  • 1
  • 6
  • 14
  • 1
    I don't think this it the problem. It appears that the jquery tools library doesn't work like a plugin where you need the jquery library included seperately. See the [http://flowplayer.org/tools/download/index.html](download page) for that library. – Mark Hildreth Mar 13 '11 at 19:06
  • Sorry, f'd up the formatting and can't change: [download page](http://flowplayer.org/tools/download/index.html) – Mark Hildreth Mar 13 '11 at 19:11