1

I'm trying to add smooth scrolling within a page. I did find out it could be done using jQuery.LocalScroll.

What I've done so far:
1. I use Zen subtheme, so into my .info file I put:
scripts[] = js/jquery.scrollTo.js
scripts[] = js/jquery.localscroll.js

2. I put jquery.scrollTo.js and jquery.localscroll.js into js folder of my theme.

Unfortunately scrolling does not work properly. I don't know much about jQuery and integrating it into Drupal. If someone is kind enough to guide me step by step how to make it work, I'll be very grateful.

1 Answer 1

1

When you view the source are the js files you added in the head? If not you'll need to clear your cache. Changes to theme .info files do not take effect until you clear your cache.

If it's a js error then it would be helpful to have some more details.

3
  • Yes, they are in the head. I've cleared cache. I tested these scripts with a HTML page and they work fine after adding: <script> $(document).ready(function() { $.localScroll(); }); </script> Unfortunately, I have no idea how to do this in Drupal.
    – mivoligo
    Mar 27, 2011 at 18:07
  • 2
    $(document).ready now needs to be wrapped in (function($){ $(document).ready(function() { your local scroll code goes here }); })(jQuery); if you are using D7
    – Jepedo
    Mar 28, 2011 at 19:05
  • many thanks for trying to help me. After your suggestion I made another .js file named "documentReady.js" which looks like: (function($){ $(document).ready(function() { $.localScroll(); }); })(jQuery); I put link to this file in my theme .info file. And finally I got it working. Thanks again.
    – mivoligo
    Mar 28, 2011 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.