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

395
Views
jQuery datatables: prueba si el complemento datatables está inicializado

Quiero verificar si un elemento de tabla con, por ejemplo, id="datatable" está inicializado en tablas de datos. Algo como esto:

 if ($('#datatable').dataTable().initialized) { alert("initialized!"); } else { alert("not initialized!"); }

¿Cómo puedo hacer eso? ¡Gracias!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede la función fnIsDataTable en jQuery datatable

 var ex = document.getElementById('example'); if ( ! $.fn.DataTable.fnIsDataTable( ex ) ) { $(ex).dataTable(); }

Puedes encontrar más información en api

over 4 years ago · Santiago Trujillo Report

0

Primero, agregue un nombre de clase especial cuando esté inicializando tablas de datos:

 $('.datatable').not('.initialized').addClass('initialized').dataTable()

Y ahora puedes distinguirlos por nombre de clase:

 alert( $('#datatable').hasClass('initialized') )
over 4 years ago · Santiago Trujillo Report

0

Siento que seguir es la respuesta correcta a esto.

 $(document).ready(function(){ if (jQuery().dataTable) { // your code to do some detaul set ups } });

Por ejemplo

 $(document).ready(function(){ if (jQuery().dataTable) { $.extend( $.fn.dataTable.defaults, { iDisplayLength : 200, aLengthMenu : [[100, 200, 300, -1], [100, 200, 300, "All"]], }); } });

De esta manera, if(jQuery().<libname>) debería poder verificar cualquier biblioteca cargada o no.

over 4 years ago · Santiago Trujillo 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!