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

331
Views
.each(function()) not looping at loading page but yes a refreshing with dedicated button

I've been making a page to load a list of tasks from a database, it works fine.

I've been asked to add a title on hover to check description without having to click on a task, for easy management.

I've done that by looping each tr in a table and adding the title with .attr('title','test');.

This is the code:

console.log("runs?");
that.tableSalidas.row(this).$('tr').each(function(){
    data =  that.tableSalidas.row(this).data();
    $(this).attr('title', data.observaciones);
    console.log("Working..");
});
console.log("yes...");

The console only prints out:

runs?
yes...

Only after I hit a reload button I have, or a timer I have set up calls on the api again, the title will be added and the console.log i have in the loop logs...

runs?
(3) Working..
yes...

adding the titles too...

Title working

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As written in a previous comment, the code block seems to be executed before the datatable gets filled with data. So it needs to be delayed to when it is guaranteed that the data is there. Check out the init event: https://datatables.net/reference/event/init

Something like the following should work:

that.tableSalidas.on('init', function () {
    console.log("runs?");
    that.tableSalidas.row(this).$('tr').each(function(){
        data =  that.tableSalidas.row(this).data();
        $(this).attr('title', data.observaciones);
        console.log("Working..");
    });
    console.log("yes...");
});
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!