Friday, April 19, 2013

AUI Events

Events can easily be handled through simple AUI methods.

e.g. we can bind an event to a button to navigate to a different page simply through AUI.

<portlet:renderURL var="addEntityURL">
       <portlet:param name="jspPage" value="/html/custom/add_entity.jsp"/>
</portlet:renderURL>

<aui:button-row id="<portlet:namespace />custom-button-row">
      <aui:script use="aui-button-item">
            var buttonRow = A.one("#<portlet:namespace />custom-button-row");
            var buttonLabel = "<liferay-ui:message key="add" />";
           
            new A.ButtonItem({
                icon: 'plusthick',
                label: buttonLabel,
                handler: function(event) {
                    location.href =  "<%=addEntityURL%>";
                }
            }).render(buttonRow);
        </aui:script>
</aui:button-row>

In this way we have achieved navigation though AUI event binding.
Some more complex things, depending on the complexity, could also be achieved using this.

No comments: