Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 以编程方式关闭“Liferay”对话框_Javascript_Dialog_Liferay 6 - Fatal编程技术网

Javascript 以编程方式关闭“Liferay”对话框

Javascript 以编程方式关闭“Liferay”对话框,javascript,dialog,liferay-6,Javascript,Dialog,Liferay 6,我有一个Liferay对话框,我想关闭这个对话框,并希望将我的url重定向到一个页面 我是这样做的 <aui:column columnWidth="16" > <%if(UserGroupRoleLocalServiceUtil.hasUserGroupRole(u.getUserId(), groupId, role.getRoleId())){ %> <input value="delete" type="button" onclick="documen

我有一个Liferay对话框,我想关闭这个对话框,并希望将我的url重定向到一个页面

我是这样做的

<aui:column columnWidth="16" >

<%if(UserGroupRoleLocalServiceUtil.hasUserGroupRole(u.getUserId(), groupId, role.getRoleId())){ %>

<input value="delete" type="button"  onclick="document.location.href='
<portlet:actionURL name="deleteUserRole"><portlet:param name="memberId" value="<%= memberIdStr %>"/>
<portlet:param name="organization" value="<%=  Long.toString(organizationID) %>"/></portlet:actionURL>'"  />
    <%} %>
            </aui:column>


public void deleteUserRole(ActionRequest actionRequest,ActionResponse actionResponse){

// process to delete user role

    Role r = RoleLocalServiceUtil.getRole(org.getCompanyId(),
                    "Power User");


    UserGroupRoleLocalServiceUtil.deleteUserGroupRoles(userID, groupId, new long[] { r.getRoleId() });

        actionResponse.sendRedirect("/group/employee/empHome");                 


}
<input value="delete" type="button"  onclick="javascript:closePopUp;document.location.href='
<portlet:actionURL name="deleteUserRole"><portlet:param name="memberId" value="<%= memberIdStr %>"/>
<portlet:param name="organization" value="<%=  Long.toString(organizationID) %>"/></portlet:actionURL>'"  />





<script type="text/javascript">
function closePopUp(){
top.document.getElementById('closethick').click();
}
</script>

保存弹出窗口引用,并在以后使用该引用关闭弹出窗口:

var myPopup;
AUI().all('.employee-dialog').on(
    'click',
    function(event){
      [..]
      myPopup = Liferay.Util.openWindow([...]);
    }
  );
使用
onclick
中保存的弹出引用:

<input value="delete" type="button" onclick="myPopup.close();document.location.href='
    [...]

最后,我可以用这种方式关闭此对话框

<aui:column columnWidth="16" >

<%if(UserGroupRoleLocalServiceUtil.hasUserGroupRole(u.getUserId(), groupId, role.getRoleId())){ %>

<input value="delete" type="button"  onclick="document.location.href='
<portlet:actionURL name="deleteUserRole"><portlet:param name="memberId" value="<%= memberIdStr %>"/>
<portlet:param name="organization" value="<%=  Long.toString(organizationID) %>"/></portlet:actionURL>'"  />
    <%} %>
            </aui:column>


public void deleteUserRole(ActionRequest actionRequest,ActionResponse actionResponse){

// process to delete user role

    Role r = RoleLocalServiceUtil.getRole(org.getCompanyId(),
                    "Power User");


    UserGroupRoleLocalServiceUtil.deleteUserGroupRoles(userID, groupId, new long[] { r.getRoleId() });

        actionResponse.sendRedirect("/group/employee/empHome");                 


}
<input value="delete" type="button"  onclick="javascript:closePopUp;document.location.href='
<portlet:actionURL name="deleteUserRole"><portlet:param name="memberId" value="<%= memberIdStr %>"/>
<portlet:param name="organization" value="<%=  Long.toString(organizationID) %>"/></portlet:actionURL>'"  />





<script type="text/javascript">
function closePopUp(){
top.document.getElementById('closethick').click();
}
</script>

函数closePopUp(){
top.document.getElementById('closethick')。单击();
}

如何打开弹出对话框?请显示代码。@GaborSch我已经为弹出对话框添加了代码。我在我的js文件中员工对话框函数的上方添加了变量
myPopup
,然后尝试按所示在onclick上调用它,但它既没有关闭弹出窗口,也没有调用我的
,这可能是可见性问题。在顶层声明
myPopup
,这样您就可以在
onclick
匿名块中访问它。是的,我已经在文件的顶部添加了这个变量,但是当我单击按钮时,它并没有调用我的,实际上它在firebug错误模式中给我错误作为参考错误:myPopup没有定义。我已经在另一个portlet中定义了js文件,我正在从另一个portlet调用它,这是我们得到这个错误的原因吗?@Ran可能。尝试在窗口级别定义:
window.myPopup=…
window.myPopup.close()