javascript - Liferay 6.2 modal add callback on close - Stack Overflow

I need to excute a generic function (console.log) on closing (on hide) modal window created with this j

I need to excute a generic function (console.log) on closing (on hide) modal window created with this javascript code:

    YUI().ready(function(A) {
        YUI().use('aui-base','liferay-util-window', function(A) {
            Liferay.Util.Window.getWindow(
                {
                    title : title,
                    uri: url,
                    dialog: {
                        cache: false,
                        modal: true
                    }
                }
            ).on('hide', function() {
                  console.log("Modal closed")});

        });
    });

'url' and 'title' are two variables passing from code above.
It doesn't work.
Any suggestion?

I need to excute a generic function (console.log) on closing (on hide) modal window created with this javascript code:

    YUI().ready(function(A) {
        YUI().use('aui-base','liferay-util-window', function(A) {
            Liferay.Util.Window.getWindow(
                {
                    title : title,
                    uri: url,
                    dialog: {
                        cache: false,
                        modal: true
                    }
                }
            ).on('hide', function() {
                  console.log("Modal closed")});

        });
    });

'url' and 'title' are two variables passing from code above.
It doesn't work.
Any suggestion?

Share Improve this question edited Mar 19, 2014 at 9:41 Olaf Kock 48.2k9 gold badges62 silver badges91 bronze badges asked Mar 18, 2014 at 17:50 tommynicolettitommynicoletti 1401 silver badge7 bronze badges 1
  • is "hide" definitly the name of the event that close s the window? – JF it Commented Mar 18, 2014 at 17:58
Add a ment  | 

3 Answers 3

Reset to default 3

This will not work until you set destroyOnHide dialog option to true.

By default it is set to false, hence the popup will only be hidden.

See below:

YUI().ready(function(A) {
    YUI().use('aui-base','liferay-util-window', function(A) {
        Liferay.Util.Window.getWindow({
            title : title,
            uri: url,
            dialog: {
                destroyOnHide: true,
                cache: false,
                modal: true
            }
        }).after('destroy', function(event) {
                alert('DESTROY MODAL!');
        });
    });
});

Then you will be able to intercept destroy event with after() method as usual.

Hi replace your on('hide' with this:

YUI().ready(function(A) {
    YUI().use('aui-base','liferay-util-window', function(A) {
        Liferay.Util.Window.getWindow(
            {
                title : title,
                uri: url,
                dialog: {
                    cache: false,
                    modal: true
                }
            }
      ) on: {
      close: function(event) {
              console.log("Modal closed")});

    });
});

The right event called on dialog close is destroy event.

Liferay Window extends A.Component which has destroy event. In fact to close a Window the right way is to call desploy() method.

AUI().ready(function(A) {
    AUI().use('aui-base','liferay-util-window', function(A) {

        Liferay.Util.Window.getWindow(
            {
                title : title,
                uri: url,
                dialog: {
                    cache: false,
                    modal: true
                }
            }
        ).after('destroy', function() {
              console.log("Modal closed");
        });

    });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745575725a4633951.html

相关推荐

  • javascript - Liferay 6.2 modal add callback on close - Stack Overflow

    I need to excute a generic function (console.log) on closing (on hide) modal window created with this j

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信