我想在前端图像编辑器对话框出现后运行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)
);
}
它可以工作,但是在加载所有对话框内容之前它正在执行。对话框完全加载后如何运行脚本?谢谢!
答案 0 :(得分:-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)
);
}