Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

349
Vistas
Dialog (Jquery) only working on second click and is showing Cannot read property 'call' of undefined

I am trying to implement a dialog in my code but the dialog is only working on a second click the first time the page is loaded. After that, is works good every time I click the button.

The first time I click the button is giving me the following error:

Uncaught TypeError: Cannot read property 'call' of undefined
    at n.(:8000/anonymous function).(anonymous function)._trigger (http://localhost:8000/?package=js:41:23960)
    at n.(:8000/anonymous function).(anonymous function)._trigger (http://localhost:8000/?package=js:41:5374)
    at n.(:8000/anonymous function).(anonymous function)._createWidget (http://localhost:8000/?package=js:41:7432)
    at new n.(:8000/anonymous function).(anonymous function) (http://localhost:8000/?package=js:41:4957)
    at HTMLDivElement.<anonymous> (?package=js:41)
    at Function.each (?package=js:36)
    at i.fn.init.each (?package=js:36)
    at i.fn.init.n.fn.(:8000/anonymous function) (http://localhost:8000/?package=js:41:6582)
    at i.fn.init.t.(:8000/anonymous function) [as draggable] (http://localhost:8000/?package=js:41:235499)
    at n.(:8000/anonymous function).(anonymous function)._makeDraggable (http://localhost:8000/?package=js:41:161342)

Can you help me to understand why the first time I have to do a double click?

$("#myAlertButton2").click(showDialog1)

function showDialog1() {
  $("#dialog1").dialog({
    title: 'Patient Profile Export Tool',
    close: (event, ui) => {
      $(this).dialog("destroy");
    }
  });

  $("#dialog1").dialog("option", "width", 250);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css" />

<div>
  <h3>Patient Profile Export Tool</h3>
  
  <div>
    <button id='myAlertButton2'>Double Click to Generate Report</button>
  </div>
  
  <div id="dialog1">
    <h4>Please Select a Subject</h4>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda