Datatables + jQuery 1.7.2 problem

Datatables + jQuery 1.7.2 problem

alexandremarquesalexandremarques Posts: 8Questions: 0Answers: 0
edited April 2012 in General
After upgrading my jQuery to 1.7.2 I got a weird problem on my DataTables.
Here are the steps to reproduce the error:

Step 1: Create a table with more than 20 rows
Step 2: Add textbox on all rows @ the second column with this code:
"fnDrawCallback": function () {
$("#ObjectAmount tbody tr").each(function(){
var value = $(this).children().eq(2).children().attr("id");
var html;
if (value == undefined) {
value = $(this).children().eq(1).text();
html = '';
$(this).children().eq(1).html(html);
}
$(this).mouseover(function(){
$(this).addClass("ui-state-hover");
}).mouseout(function(){
$(this).removeClass("ui-state-hover");
});
});
}
Step 3: Change textbox value on any row
Step 4: Go to the next page
Step 5: Go back to the first page.

All the data that I typed on the first page is gone. If I had typed anything on second page, it will be gone as soon as I change the page too.
That was working on previous datatables release.

Replies

  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    > That was working on previous datatables release.

    So it is the DataTables versions which cause the problem? i.e. one works with jQuery 1.7.2 and one doesn't? What versions are they?

    Can you link to your example please?

    Allan
  • alexandremarquesalexandremarques Posts: 8Questions: 0Answers: 0
    I was using Datatables 1.75 with jQuery 1.6.2 and it was working perfectly.
    I upgraded to 1.9 and jQuery 1.7 now got this problem. That happened once when I tried to update jQuery with this datatables version, but also occurs with latest datatables/Jquery version

    As I have no idea why this occur this is my workaround but fnRender seems to work fine for me:

    [code]
    $('#unitList').dataTable({
    "bRetrieve": true,
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "bProcessing": true,
    "sAjaxSource": 'index.php?modulo=List-ListUnits,
    "aoColumns": [
    {
    "bSearchable": false,
    "bVisible": false
    },
    null,
    { "fnRender": function (o, val) {
    return '';
    }
    },
    {
    "bVisible": false
    } ,
    {
    "bVisible": false
    }

    ],
    "aaSorting": [[ 1, "asc" ]],
    "fnDrawCallback": function () {
    $("#UnidadeBP_Listagem tbody tr").each(function(){
    $(this).mouseover(function(){
    $(this).addClass("ui-state-hover");
    }).mouseout(function(){
    $(this).removeClass("ui-state-hover");
    });
    });
    }
    });
    [/code]
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    That looks like it should be working okay to me. I know that IE6 can have issues with INPUT elements and paging, but I presume you are not using IE6?

    Can you link to your example please?

    Allan
  • alexandremarquesalexandremarques Posts: 8Questions: 0Answers: 0
    As our development server is just intranet I cant link to you.
    This code snippet solved my problem so i guess i should just stop to add DOM dinamically. :P
    Whole system is upgraded, thanks allan anyway!
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    Good stuff :-) Great to hear you got it all working.

    Allan
This discussion has been closed.