Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!