0

我想在前端图像编辑器对话框出现后运行 javascript 代码。我怎样才能做到这一点?这就是我到目前为止所拥有的:

function ${namespace}editWithImageEditor(
    editItemURL, uploadItemURL, fileEntryFilename, fileEntrySrc) {

    Liferay.Util.editEntity(
        {
            dialog: {
                destroyOnHide: true,
                zIndex: 100000
            },
            id: 'dlImageEditor',
            stack: false,
            title: '${editLanguageKey} ' + fileEntryFilename,
            uri: editItemURL,
            urlParams: {
                entityURL: fileEntrySrc,
                saveParamName: 'imageEditorFileName',
                saveURL: uploadItemURL
            },
            dialogIframe: {
                after: {
                    load: function(event) {}
                }
            }
        },
        AUI().bind('${namespace}_onSaveEditSuccess', this)
    );
}

它可以工作,但它在加载所有对话框内容之前执行。对话框完全加载后如何运行脚本?谢谢!

4

1 回答 1

-1

只需添加一个延迟/超时来延迟您要运行的 javascript,我在这里设置了 1 秒的延迟,但是您可以将其设置为任意短或任意长

function ${namespace}editWithImageEditor(
editItemURL, uploadItemURL, fileEntryFilename, fileEntrySrc) {

Liferay.Util.editEntity(
    {
        dialog: {
            destroyOnHide: true,
            zIndex: 100000
        },
        id: 'dlImageEditor',
        stack: false,
        title: '${editLanguageKey} ' + fileEntryFilename,
        uri: editItemURL,
        urlParams: {
            entityURL: fileEntrySrc,
            saveParamName: 'imageEditorFileName',
            saveURL: uploadItemURL
        },
        dialogIframe: {
            after: {
                load: window.setTimeout(function(event) {
                          //code here
                      }, 1000)
                }
            }
        }
    },
    AUI().bind('${namespace}_onSaveEditSuccess', this)
);

}

于 2017-01-18T12:56:50.600 回答