Monday, January 5, 2015

Make a request in Liferay using AlloyUI

AUI().ready('aui-io-request', function(A) {
    Liferay.on(
             'event_name',
             function(data) {
                 var param = event.data;
                 if(param != null) {

                      //use blockUI to block screen
                     $.blockUI({ message: null }); 

                     A.io.request(searchUrl, {
                         data: {
                             keyword: param ,
                         },
                        dataType: 'json',
                        on: {
                            success : function() {
                                     // do something here

                                    $.unblockUI();
                            },
                            failure : function() {
                                $.unblockUI();
                            }
                        }
                    });
                 }

         })
});

To fire event, using:

Liferay.fire('event_name', {data: param });

References:
http://proliferay.com/alloy-ajax-liferay-portlet/ 

No comments:

Post a Comment