问题
I need some help understanding Liferay 7 themes, specifically to use jQuery plugins. As I am having the same issue as in this thread: https://web.liferay.com/community/forums/-/message_boards/view_message/79089004
"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..
$(".content").mCustomScrollbar();
is just a no go, and I can't figure it out why..
回答1:
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:
<script>
define._amd = define.amd;
define.amd = false;
</script>
<script type="text/javascript" src="${javascript_folder}/mCustomScrollbar.js"></script>
<script>
define.amd = define._amd;
</script>
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!
来源:https://stackoverflow.com/questions/39490126/jquery-plugin-in-a-liferay-7-theme