0

enter image description hereThis question has been asked, but not really answered. It is NOT as simple as has been suggested in

This response

If it were, there would be no reason to have a module like jquery_plugin

Simply putting a line in the theme info file like

scripts[] = js/jquery.scrollme.js

Does not work. In the case above, the script does actually show up on the rendered page, but the function(s) within it result in "undefined".

In the case of scrollme.js, are there dependencies that need to be included?

I fought this thing with hoverintent for a day or two, and finally just punted and added the module "hoverintent". And incidentally, the fact that the hoverintent module exists suggests strongly that one can not simply throw the hoverintent.js code into a directory and load it with a script from the theme info file.

Any experienced direction would be really appreciated!

6
  • You're likely trying to use the plugin before the plugin is loaded. Ensure that scrollme.js is being included before your custom JS that tries to use it. Commented Jun 30, 2015 at 0:07
  • You might be right! I know for a fact that it isn't being loaded EVER. So... how do I "ensure" that is loaded? I created a new custom module with the following: $path = drupal_get_path('module', 'scrollme'); drupal_add_js($path . '/js/jquery.scrollme.js'); And... I can clearly see the js referenced in the "source" for the rendered page. But the debugger is not listing jquery.scrollme.js as one of the module. And further, "scrollme" is still flagged as "undefined"
    – sea26.2
    Commented Jun 30, 2015 at 0:30
  • $path = drupal_get_path('module', 'scrollme'); does nothing unless you have a module called scrollme. You can go back to using the .info method and just make sure you have your custom JS added after the scrollme JS. ie.. scripts[] = js/jquery.scrollme.js; scripts[] = js/customJSthatCallsScrollme.js; Commented Jun 30, 2015 at 1:02
  • Also, it would help if you showed your custom JS that is calling scrollme Commented Jun 30, 2015 at 1:03
  • There were actually 2 (two) lines in that snipped of code that I tried to display. The first sets the path: $path = drupal_get_path('module', 'scrollme') The second does the "work". drupal_add_js($path . '/js/jquery.scrollme.js'); There is NO custom JS that is calling the scrollme function. Scrollme.js is the name of the plugin. It works simply by adding the appropriate class to DIVs I've tested it on standalone HTML. It works beautifully. The problem is simply adding the scrollme.js plugin to Drupal7. I've gotten feedback from the folks at Lullabot. Some known issues. Waiting to hear.
    – sea26.2
    Commented Jun 30, 2015 at 3:19

1 Answer 1

1

You embedded your module the right way. The error stems probably from the fact, that ScrollMe needs jQuery 1.8 minimum, whereas Drupal 7 only ships with 1.4.

You have many options of updating your jQuery version in Drupal.

3
  • Nicely done! I can't confirm yet that this solved the problem. But, I did repro the error with my standalone code. You're right; ScrollMe will not run on jQuery 1.4. How did you find that? The documentation for ScrollMe seems to be nearly non-existent. I'm not finding that requirement documented.
    – sea26.2
    Commented Jun 30, 2015 at 15:33
  • Thank you for the tip. You were right. I simply used the jQuery_update module and updated to v1.10.2 Code is working as expected
    – sea26.2
    Commented Jun 30, 2015 at 17:24
  • 1
    The easiest way to check dependencies nowadays is to simply check the corresponding bower.json file. But you're right, I have abandoned the Scrollme lib as well – mainly out of performance reasons. Paul Lewis' writeup is good starting place for vanilla alternatives. Commented Jul 1, 2015 at 7:25

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.