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

131
Visualizações
jquery UI Dialog doesn't see variables defined outside of the dialog

I have TypeScript closure with function body like this where constants defined outside of the dialog(). Inside the Dialog Save button, the variables are undefined. Please help? Thanks.

    const oldAnswers: Array<IUserAnswer> = new Array<IUserAnswer>();
    const newAnswers: Array<IUserAnswer> = new Array<IUserAnswer>();
    const updatedAnswers: Array<IUserAnswer> = new Array<IUserAnswer>();
    
    $('form').map(function(){  
        //.....omitted code to change the above variables
    }
    $("#dialog").dialog({
      resizable: true,
      height: "auto",
      width: 400,
      modal: true,
      buttons: {
        "Save": function () {
          let thisUrl: string = $('#submit').attr('formAction');
          //ToDo: ajax post here
          let postBackModel: AjaxPostbackModel;
          postBackModel.NewAnswers = newAnswers;
          postBackModel.OldAnswers = oldAnswers;
          postBackModel.UpdatedAnswers = updatedAnswers;
          alert('ToDo: sending ajax postBackModel to ' + thisUrl);
        },
        Cancel: function () {
          $(this).dialog("close");
        }
      }
    });

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Thanks for your response. I solved the problem. I didn't initialize the postBackModel in the Save. Here is the correction.

let postBackModel: AjaxPostbackModel = <AjaxPostbackModel>{};

utton block.

about 4 years ago · Juan Pablo Isaza Relatório
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