I have a command button("Send") for sending notification on a VF page, when I click the send button , it sends the notification, but the vf page popup doesn't get closed. On clicking the second time on the send button the vf page pop-up gets closed. In the first click only, it sends the notification using a flow but does not get closed. Below is the syntax,
<apex:commandButton value="Send" action="{!submitNotification}" onclick="handleSubmit()"/>
below is the script I have added it in vf page for closing the popup,
function handleSubmit() {
console.log("Test inside handlesubmit1");
if ({!isNotificationSent}) {
console.log("Test inside handlesubmit");
closeLightbox();
}
return true;
}
Can anyone please guide, to resolve this.
Hi,
Try this,
<apex:commandButton value="Send" action="{!submitNotification}" oncomplete="handleSubmit();" />
<script>
function handleSubmit() {
console.log("Test inside handlesubmit1");
// Check if the notification has been sent successfully
if ({!isNotificationSent}) {
console.log("Test inside handlesubmit");
closeLightbox(); // Close the popup
}
}
function closeLightbox() {
// Your code to close the popup (depends on how you are handling the lightbox)
console.log("Popup closed");
// e.g. if you are using jQuery:
// $("#yourPopupElement").hide();
}
</script>