掲示板
close Liferay Dialog
Hello,
I use a Dialog to write a message within a portlet. The code looks like:
I don't understand why "A.one('#portangoPrivateMessageDialog');" or "Liferay.Util.Window.getById('#portangoPrivateMessageDialog');" return "undefined".
I see there is a div element with this id containing the dialog.!!!
Please help:-)!,
Morad.
I use a Dialog to write a message within a portlet. The code looks like:
<aui:script>
function openPrivatMessageDialog(dialogId, url, title, width, height) {
YUI().ready(function(A) {
YUI().use('aui-base','liferay-util-window', function(A) {
var messagingDialog = Liferay.Util.Window.getWindow (
{
title : title,
uri: url,
id: dialogId,
dialog: {
cache: false,
modal: true,
destroyOnClose:true,
width: width,
height: height,
toolbars: {
footer: [
{
label: '<%= UnicodeLanguageUtil.get(pageContext, "cancel") %>',
on: {
click: function() {
messagingDialog.hide();
}
}
}
]
}
}
}
);
messagingDialog.on('hide', function() {
console.log("Modal closed")
});
messagingDialog.render();
});
});
}
</aui:script>
<% String sendMessagePopup = "javascript:openPrivatMessageDialog('portangoPrivateMessageDialog','" + sendMessageURL.toString() + "', '" + LanguageUtil.get(pageContext, "new-message") + "' , 840, 960);"; %>
<div style="clear: both; height: 1em"></div>
<div class="portango-context-buttons right">
<div class="btn-group">
<aui:button cssClass="btn portango-action-button" value="send-message" onclick="<%=sendMessagePopup%>" />
</div>
</div>
But I can't close the dialog after sending the message. The code to send/close looks like:
A.io.request(
'<liferay-portlet:resourceurl id="sendMessage"></liferay-portlet:resourceurl>',
{
dataType: 'json',
form: {
id: form,
upload: true
},
on: {
complete: function(event, id, obj) {
loadingMask.hide();
// $('#portangoPrivateMessageDialog').hide();
// A.DialogManager.closeByChild('#portangoPrivateMessageDialog');
// var dialog = Liferay.Util.Window.getById('#portangoPrivateMessageDialog');
// dialog.destroy();
var responseText = obj.responseText;
var responseData = A.JSON.parse(responseText);
if (responseData.success) {
console.info("SUCESS");
}
else {
var messageContainer = A.one('#<portlet:namespace />messageContainer');
if (messageContainer) {
messageContainer.html('<span class="portlet-msg-error">' + responseData.message + '</span>');
}
}
// var messageDialog = A.one('#portangoPrivateMessageDialog');
var messageDialog = Liferay.Util.Window.getById('#portangoPrivateMessageDialog');
if(messageDialog) {
console.info("close message dialog");
messageDialog.hide();
}
else {
console.info("couldn't find message dialog!");
}
}
}
}
);
I don't understand why "A.one('#portangoPrivateMessageDialog');" or "Liferay.Util.Window.getById('#portangoPrivateMessageDialog');" return "undefined".
I see there is a div element with this id containing the dialog.!!!
Please help:-)!,
Morad.
8年前 に Andrew Jardine によって更新されました。
RE: close Liferay Dialog
Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Morad,
I used a modal recently to provide users a way to add configurations. I used the code below to launch and kill the modal when done.
checkout the success: portion. Perhaps this would work for you as well?
I used a modal recently to provide users a way to add configurations. I used the code below to launch and kill the modal when done.
A.one('#<portlet:namespace />save').on('click', function(event) {
var A = AUI();
var url = '<%= saveActionURL.toString() %>';
A.io.request(url,
{
method : 'POST',
form : {
id : '<portlet:namespace />fm'
},
on : {
success : function() {
Liferay.Util.getOpener().refreshPortlet();
Liferay.Util.getOpener().closePopup('dialog');
},
error : function() {
alert("Error occurred.");
}
}
});
});
checkout the success: portion. Perhaps this would work for you as well?