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

207
Views
Ejecute JavaScript en la ventana modal de Fancybox (use .on() para ordenar las columnas de la tabla)

Soy un programador novato con conocimientos básicos de JS y JQuery. Estoy usando Fancybox para extraer una tabla HTML a través de Ajax y mostrársela a los usuarios de nuestro sistema.

HTML (dentro de Fancybox):

 <table> <thead> <tr> <th class="priority-2 sortable date" style="min-width:150px">Date / Time</th> <th class="priority-2 sortable text" style="min-width:150px">Changed By</th> <th class="priority-1 sortable text" style="min-width:150px">Previous Value</th> <th class="priority-1 sortable text" style="min-width:150px">New Value</th> </tr> </thead> <tbody> <tr> <td class="priority-2">15/12/2021 11:23</td> <td class="priority-2">John Smith</td> <td class="priority-1">Stalled</td> <td class="priority-1">Test</td> </tr> <tr> <td class="priority-2">14/12/2021 16:58</td> <td class="priority-2">David Jones</td> <td class="priority-1">Live</td> <td class="priority-1">Stalled</td> </tr> </tbody> </table>

Tengo algo de Javascript que uso en otros lugares para ordenar las tablas cuando se hace clic en el que funciona bien. Sé que para que esto funcione en el contenido de Ajax tengo que cambiar .click() para usar .on() pero con mi conocimiento limitado no puedo hacer que la sintaxis funcione correctamente.

JS (en un archivo .js separado):

Código original:

 $('thead th.sortable').each(function(index, listItem) { $(this).click(function(e){ e.preventDefault(); // sort column code here }); });

Mi intento de modificar el código:

 $('thead th.sortable').each(function(index, listItem) { $(this).on('click', function(e) { e.preventDefault(); // sort column code here }); });

Intenté usar $ (documento). (esto), etc., pero fue en vano. Lo anterior funciona en el HTML principal pero no en la ventana de Fancybox.

Uso el siguiente código JS para mostrar/ocultar secciones que he adaptado con éxito para que funcionen en la ventana de Fancybox:

 $(document).on('click', '.header-row', function(e) { // Toggle Section code here });

Se agradece cualquier ayuda con la sintaxis que necesito. Disculpas de antemano por el escaso conocimiento de codificación.

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