0

I have a custom module that has a JavaScript file in it. The JavaScript file is calling on the Vimeo API, which has a custom library created for it (similar to jQuery).

How can I use this library in the custom module's .js file? I've tried putting Froogaloop (the Vimeo library) inside of sites/all/libraries and then using its syntax it in the .js file within the custom module, but it's not picking the library up.

1

Is your js file even working?

Is your JavaScript file jQuery?

In Drupal, you wrap your jQuery code like this

(function ($) {

    //code goes here

})(jQuery);

For Example:

(function ($) {

    $(document).ready(function() {
         $(".button").click(function () {
             $(this).next('.content').hide();
         });
    });

})(jQuery);

Not sure if you did this already.

Did you also add the frugaloop js to your module? Putting it on the libraries folder doesn't do anything unless you call it.

Use the function drupal_add_js to call it.

  • Correct, I do have it wrapped and jQuery is functioning correctly. However, I have not called the library in the custom module. I'll give that an attempt. Thank you. – Michael W Sep 21 '15 at 0:16
  • When in doubt, just look at how other modules are calling their js files. – No Sssweat Sep 21 '15 at 0:21
  • 1
    Words of wisdom - Froogaloop now works. Thank you!! – Michael W Sep 21 '15 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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