I want to load a script and after executing this script launch a trigger. Formerly we did it with jquery and now we go to Alloyui. I'm trying to do this in Liferay 7 with AlloyUI. But I can't find the way, how can I do it?
jQuery.getScript("http://localhost:8082/js/test.js")
.done(function( script, textStatus ) {
work();
$(document).trigger('testEvent');
}
Thank you
Use
aui:scriptto load modules within Liferay DXP (7.x).The
aui:scripttag is a JSP tag that loads JavaScript in script tags on the page, while ensuring that certain resources are loaded before executing.It tag supports the following options:
Example: if you want to load the module
fooand use itsdefaultfunction, you can use the following:Here is the real application that is being used at official liferay portal: https://github.com/liferay/liferay-portal/blob/master/modules/apps/commerce/commerce-order-web/src/main/resources/META-INF/resources/commerce_order/general.jsp#L430-L437. Where it calls the JS module at here: https://github.com/liferay/liferay-portal/blob/master/modules/apps/commerce/commerce-frontend-js/src/main/resources/META-INF/resources/components/summary/Summary.js