Follow these steps to load modules with <aui:script>
:
-
Add the following declaration to your portlet’s JSP:
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
-
Add the
<aui:script>
tag and use theuse
attribute to load AlloyUI/YUI modules:<aui:script use="aui-base"> A.one('#someNodeId').on( 'click', function(event) { alert('Thank you for clicking.') } ); </aui:script>
This loads the aui-base
AlloyUI component and makes it available to the code
inside the aui:script
.
In the browser, the aui:script
translates to the full JavaScript shown below:
<script type="text/javascript">
AUI().use("aui-base",
function(A){
A.one('#someNodeId').on(
'click',
function(event) {
alert('Thank you for clicking.')
}
);
}
);
</script>
Wonderful! Now you know how to load AUI/YUI modules in AUI scripts.