如何关闭Liferay中的弹出窗口? [英] How to close a popup window in Liferay?

查看:191
本文介绍了如何关闭Liferay中的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在弹出窗口上加载WebContent编辑portlet:

I load the WebContent edit portlet on a Popup window using the following code:

<liferay-ui:icon
    image="edit"
    label="true"
    message="news-edit-url"
    url="${oneNews.newsEditUrl}"
    />

editUrl:

taglibEditURL = "javascript:Liferay.Util.openWindow({dialog: {width: 960}," + 
    "id: '" + renderResponse.getNamespace() + "'," +
    "title: '" + LanguageUtil.format(request.getLocale(), "edit-x", HtmlUtil.escape(assetRenderer.getTitle(request.getLocale()))) + "'," +
    "uri:'" + HtmlUtil.escapeURL(editPortletURLString) + "'});";

保存或发布内容时,Portlet会加载到弹出窗口中.我希望关闭弹出窗口,并刷新带有editURL链接的portlet.

When the content is saved or published, the portlet is loaded on the popup window. I want the popup window to close and the portlet with the editURL link to refresh.

关于此的任何帮助...

Any help regarding this...

推荐答案

以下是关闭弹出窗口的代码,该代码应该出现在打​​开弹出窗口的父页面中:

Here is the code to close the pop-up, this should be present in the parent page which opens the pop-up:

Liferay 6.1版

Liferay version 6.1

Liferay.provide(
        window,
        '<portlet:namespace />closePopup',
        function(popupIdToClose) {

            var A = AUI();

            A.DialogManager.closeByChild('#' + popupIdToClose);
        },
        ['aui-base','aui-dialog','aui-dialog-iframe']
    );

Liferay 6.2版

Liferay version 6.2

Liferay.provide(
    window,
    '<portlet:namespace/>closePopup',
        function(popupIdToClose) {

            var popupDialog = Liferay.Util.Window.getById(popupIdToClose);

            popupDialog.destroy();
        },
        ['liferay-util-window']
    );

这是刷新打开弹出窗口的portlet的代码.这应该出现在打​​开弹出窗口的父页面中:

Here is the code to refresh the portlet which opened the pop-up. This should be present in the parent page which opens the pop-up:

Liferay.provide(
        window,
        '<portlet:namespace />refreshPortlet',
        function() {

            <%-- refreshing the portlet [Liferay.Util.getOpener().] --%>
            var curPortletBoundaryId = '#p_p_id<portlet:namespace />';

            Liferay.Portlet.refresh(curPortletBoundaryId);
        },
        ['aui-dialog','aui-dialog-iframe']
    );

如何调用closePopup& refreshPortlet功能.一种方法是,只有在成功处理请求后,才能让弹出窗口刷新并从弹出窗口本身调用closePopup函数,然后也从弹出窗口中调用refreshPortlet函数.

It is up to you how to call the closePopup & refreshPortlet functions. One way is you can let the pop-up refresh and call the closePopup function from the pop-up itself only when the request is successfully processed and then call the refreshPortlet function also from the pop-up.

这是一个代码段,可帮助您从弹出窗口中调用父页面函数:

Here is a code-snippet which would help you to call parent-page functions from the pop-up:

Liferay.Util.getOpener().<portlet:namespace />closePopup(popupIdToClose);
Liferay.Util.getOpener().<portlet:namespace />refreshPortlet();

popupIdToClose与打开弹出窗口时使用的id相同,如下所示:

The popupIdToClose is the same id which is used when opening the pop-up as shown:

taglibEditURL = "javascript:"
                +   Liferay.Util.openWindow({"
                +       "dialog: {width: 960},"
                +       "id: '" + renderResponse.getNamespace() + "'," // This is the "popupIdToClose"
                +       "title: '" + LanguageUtil.format(request.getLocale(), "edit-x", HtmlUtil.escape(assetRenderer.getTitle(request.getLocale()))) + "',"
                +       "uri:'" + HtmlUtil.escapeURL(editPortletURLString)
                +       "'}"
                +   ");";

希望这会有所帮助.

这篇关于如何关闭Liferay中的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆