[solved]the pageDT will be fired 'before' the table has been redrawn: How to do 'after'?

[solved]the pageDT will be fired 'before' the table has been redrawn: How to do 'after'?

techbottechbot Posts: 9Questions: 4Answers: 0
edited July 2015 in Free community support

Hello.
I am attempting to lazy load a column of images using https://github.com/ressio/lazy-load-xt . It works fine for the first page, but doesn't work on subsequent pages. So I'm using the page event to remove the data-src attribute, like so:

$('#result_panden').on( 'page.dt', function () {
    var x = document.getElementsByClassName("images");
    var i;
    for (i = 0; i < x.length; i++) {
        x[i].removeAttr('data-src');
    }

before doing this:http://stackoverflow.com/questions/24414488/change-data-src-to-src-via-jquery

But this is triggered before the new pagination is displayed. Can you suggest an event that triggers 'after' the new pagination or an alternative method to remove the attribute?

Answers

  • techbottechbot Posts: 9Questions: 4Answers: 0

    Got it.
    I'm using draw|dt
    here is my final code (for lazy loading images beyond the first page)

    $('#result_panden').on( 'draw.dt', function () {
        var x = $(".images");
        x.each(function( index ) {
             $( this ).attr({
             src: $( this ).attr('data-src')
            }).removeAttr('data-src')
        });
    } );
    

    Essentially it copies the url from data-src to src and then removes data-src

This discussion has been closed.