Saturday, June 1, 2013

Submitting the parent form from liferay pop up window

Hi friends, sometimes in liferay after doing our stuff in the pop up window we want to send data back to parent form & submit it. So following are few steps to perform this task.

Call the following function on click of save button in liferay pop up window

<script type="text/javascript">
         
        AUI().ready('aui-dialog', function(A) {

               A.one('#<portlet:namespace />save').on('click', function() {

                              var comment = A.one('#<portlet:namespace/>declineCommentPopUp').val();

var declineComment  = Liferay.Util.getOpener().document.getElementById('<portlet:namespace />declineComment');

                              declineComment.value = comment;

Liferay.Util.getOpener().document.getElementById('<portlet:namespace />fm').action  =  '<%=declineAgreement%>';

                              Liferay.Util.getOpener().document.forms['<portlet:namespace />fm'].submit();

               });

});

</script>

In the above mentioned function 'declineCommentPopUp' & 'declineComment' are the fields available inside the form on the pop up & on the parent form respectively. '<portlet:namespace />fm' is the parent form. With the help of syntax

Liferay.Util.getOpener().document.getElementById('idOfElementOnParentForm');

we are able to access elements from the parent form & syntax

Liferay.Util.getOpener().document.forms['<portlet:namespace />fm'].submit(); 

will submit the parent form & close the pop up window.

No comments:

Post a Comment