Victor Victor - 1 year ago 391
jQuery Question

jQuery plugin in a Liferay 7 theme

I need some help understanding Liferay 7 themes, specifically to use jQuery plugins. As I am having the same issue as in this thread:

"is not a function" is occuring whenever I call the plugin function I tried to install. I am tring all the possible placements for this:

<script type="text/javascript" src="${javascript_folder}/mCustomScrollbar.js"></script>

When I inspect the page I can see the jQuery object there, but it seems the plugin is not sticking..


is just a no go, and I can't figure it out why..

Answer Source

crossposting from the Liferay Forums

Not that the cleanest solution, but if you simply want to keep loading your modules as globals, you might be able to do the following:

    define._amd = define.amd;
    define.amd = false;

<script type="text/javascript" src="${javascript_folder}/mCustomScrollbar.js"></script>

    define.amd = define._amd;

Setting the amd flag to false before loading your umd-wrapped plugins should do the trick and they should keep loading all the same.

Additionally, if you're hosting the file, you could actually replace &&define.amd by &&false or something similar in the plugin umd definition to make sure it will laod as a global as well.

Let me know if that works for you!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download