Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

345
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda