You need to sign in to do that
Don't have an account?
Agustín Medina
Close a modal automatically
I'm developing a visualforce which after query an opportunity displays a modal and the modal has a button to close itself but I want to close it automatically, does anyone knows how to do it?
My apex code is
and te visualforce is
My apex code is
public without sharing class RegistroCitas { Public String correo{get; set;} Public List<Account> cuenta = new List<Account>(); Public List<Oportunidad_Univer__c> oportunidad = new List<Oportunidad_Univer__c>(); Public PageReference pageRef = ApexPages.currentPage(); public boolean displaySuccesPopup {get; set;} public boolean displayFailedPopup {get; set;} public boolean boleano {get; set;} public RegistroCitas(){ displaySuccesPopup = false; displayFailedPopup = false; } public PageReference registrarCita(){ cuenta = [SELECT Acc_Asistio__c FROM Account WHERE PersonEmail =: correo]; if(cuenta.isEmpty()){ displayFailedPopup = true; correo = ''; return null; }else{ //Si hay cuenta oportunidad = [SELECT Id, Name, Opp_Atendio_cita__c ,CreatedDate FROM Oportunidad_Univer__c WHERE Opp_Cuenta__c =: cuenta[0].Id ORDER BY CreatedDate DESC LIMIT 1]; if(oportunidad.size() < 1){ displayFailedPopup = true; correo = ''; return null; }else{ oportunidad[0].Opp_Atendio_cita__c = True; cuenta[0].Acc_Asistio__c = True; update oportunidad; update cuenta; displaySuccesPopup = true; correo = ''; return pageRef; } } } public void closePopup(){ displaySuccesPopup = false; displayFailedPopup = false; } }
and te visualforce is
<apex:page> <apex:form > <div class="container"> <div class="cabecera centrado"> <div class="imagen"> <apex:image url="{!URLFOR($Resource.images, 'images/logoUniver-Blanco.png')}" width="500" height="100" /> </div> </div> <div class="margen centrado"> <h1 class="grande">Registro para Citas Agendadas</h1> <p><u>Favor de ingresar su correo electrónico</u></p> <apex:inputText value="{!correo}"/><br/> <br/> <apex:commandButton value="Enviar" action="{!registrarCita}"/> </div> </div> </apex:form> <apex:form > <apex:outputPanel id="tstpopup"> <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displaySuccesPopUp}"/> <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displaySuccesPopUp}"> ¡Tu cita ha quedado registrada! :)<br/><br/><br/> <apex:commandButton value="Cerrar" action="{!closePopup}" rerender="tstpopup"/> </apex:outputPanel> <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayFailedPopUp}"/> <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayFailedPopUp}"> No se encontró su cita, favor de buscar asistencia de parte de nuestro equipo en recepción.<br/><br/><br/> <apex:commandButton value="Cerrar" action="{!closePopup}" rerender="tstpopup"/> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page>
Mohammad Asim Ali
By automatically, you mean you want to close it after a time lapse. On click of your command button, when your modal pops up, call a javascript function, which in turn will call an action function after a javascript timeout. In the action function, call an apex method and make your boolean value as false used to render the popup and then rerender the modal. This will hide your modal popup.
Agustín Medina
I rewrite the code but it still doesn't work.