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

148
Views
Llamar a la función this.method() dentro de otro método

¿Hay alguna forma de llamar al método createElement() dentro checkbox.off().on('click', function () {}) del método checkBoxes() ? No puedo acceder al método dentro de la función dentro del método.

 class Lists { constructor() { this.currentList = []; this.completedList = []; } createElement( value1 = undefined, value2 = undefined, value3 = undefined, checkboxCheck = '' ) { value3.append(`<li class="list-group-item p-3"> <input type="checkbox" ${checkboxCheck}/> <span class="span-item"> ${value1} </span> <div class="float-end"> <i class="fas fa-edit mx-2"></i> <i class="fas fa-trash mx-2"></i> </div> <br /> <span class="span-time">${value2}</span> </li>`); } checkBoxes() { const checkbox = $('input[type=checkbox]'); checkbox.off().on('click', function () { this.createElement(value1, value2...) }); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hay 3 formas.

 // set 'this' to 'self' outside the function const self = this; checkbox.off().on('click', function () { self.createElement(value1, value2...) }); //use Function.prototype.bind to pass 'this' checkbox.off().on('click', function () { this.createElement(value1, value2...) }.bind(this)); //use arrow function checkbox.off().on('click', () => { this.createElement(value1, value2...) });

pero le sugiero que averigüe por qué 'esto' no funcionará en sus códigos mediante la búsqueda.

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!