Paging shown twice if .dataTable() is called consecutively

Paging shown twice if .dataTable() is called consecutively

borecastborecast Posts: 3Questions: 0Answers: 0
edited December 2011 in Bug reports
According to the API re-calling .dataTable() on a table object returns a reference to the existing datatable object.

see DataTables object retrieval in
http://datatables.net/new/1.7

But unfortunately calling .dataTable() multiple times adds the paging and the search box again.
Also DataTables 1.8.2 and the nightly build 1.8.3 is affected.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you like us to an example page that shows this please? As you can see in this demo it appears to work okay: http://live.datatables.net/arazun/edit and this is a feature I use daily so would notice almost immediately if it were broken (never mind the unit tests :-) ).

    Allan
  • borecastborecast Posts: 3Questions: 0Answers: 0
    Thank you very much for your fast response, Allen.
    I took a look at your example given - and it looks good in deed.

    I will prepare a demo for this problem and post it within 2 days.
  • borecastborecast Posts: 3Questions: 0Answers: 0
    I drilled down the problem and reproduced it:

    http://live.datatables.net/arazun/5/edit

    The problem occurs if two or more tables have the same id.
    I know that this is not allowed according to the HTML specification.
    It happened to me accidentally when I used a Repeater control in my ASP.NET environment.

    Perhaps you could add a warning message box for this case similar to the situation when reinitialisation is not allowed.

    Thanks a lot for this great plugin.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Thanks for for investigating this a bit. A document with two matching IDs is, as you say, invalid, so this is not something that I will guard against in DataTables. For example if you have two elements with an ID of "example", which one of them would document.getElementById('example') give to you? Generally speaking DataTables assumes that valid markup will be used, since anything else would add a huge amount of code to the library!

    Regards,
    Allan
This discussion has been closed.