Jquery code AFTER datable has loaded

Jquery code AFTER datable has loaded

iloopiloop Posts: 2Questions: 0Answers: 0
edited September 2018 in Free community support

Hello,
I have HREF in my datable that targets a jQuery click code at the bottom of my page.
The problem is that it has no effect because i think it must wait datatabla has loaded, is there a event for that ?
thanks

$(document).ready(function() { 
 var frameSrc = "";
     $('a[href="#modalsm"]').click(function(){
     
          $frameSrc = $(this).data( "src" );
          $('#myModalsm iframe').attr("src",$frameSrc);
 
   }); 

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @iloop ,

    I'm not seeing where the DataTable is being initialised, so it's hard to say. However, you could but the click code in initComplete, which would mean it's called after the table is fully initialised.

    Cheers,

    Colin

  • iloopiloop Posts: 2Questions: 0Answers: 0

    the datable is initialized up in the body and this code is at the bottom.
    I tried with initComplete but it did not worked ...

    thanks
    cheers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Sounds like you might have two $(document).ready blocks - couldn't you just move the DataTables into the one you're pasting.

    If that doesn't work, we're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.