views:

97

answers:

2

Hi all, i am trying to use a jQuery scrollbar called "Jscrollhorizontalpane". when i am trying to use it i get the following error message: "$(window).width is not a function" in firebug's console.

i am new to jQuery do this might be very basic but still, i dont know what that means and why there is a problem.

the scroller comes in a bundle with a few files, one of which is called "jScrollHorizontalPane.js" and i believe it holds the code for the scroller. i tried replacing $ signs there with the word "jQuery" (in case there is a conflict) but it didnt seem to help.

also important to add that on the same page i am using another jQuery scroller (a vertical one as opposed to the horizontal on mentioned above) which works just fine. the code for this one doesnt use $(window).width but uses $(window) many times...

any ideas?

+2  A: 

It sounds like you have a conflict somewhere.

I would suggest finding the route of the problem first;

  • Make sure you are including jquery.js above jScrollHorizontalPane.js in your html
  • Remove the other javascript files (other than jquery) temporarily and see if that fixes it
  • Try using different versions of jQuery, you can load them straight off google's CDN and just change the version number http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

If none of those work then update your question with a live demo link.

Alex
Using mootools and jquery can cause this conflict. The easiest solution is to load jquery in noConflict mode (call jQuery.noConflict() immediately after loading), then run all jquery statements in an anonymous function (ie, jQuery(document).ready(function($) { alert($(window).width()); }); )
John Himmelman
A: 

does changing $(window).width to $(window).width() solve your problem ?

Puaka