Datatables Checkbox Bug in Firefox

Datatables Checkbox Bug in Firefox

rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
edited March 2011 in Bug reports
I am having trouble tracking down a bug that occurs in Firefox, but not Safari. I have a data table with two columns, one of those columns are checkboxes. When a user selects some of the checkboxes, then submits the form, everything works properly. The problem is when the user click the browsers back button and views the table again. As opposed to showing the items that were originally checked, different items in the list are checked.

To see an example, please go here: http://dev2.njschooljobs.com. Click on the All Schools with Active postings link. That should bringup a modal window with the datatable.Chose Archway, Bayshore Jointure and Berlin twp. then click Apply, then Search Jobs Now button. You will see results for those schools selected. Now click the browsers back button and click on the same link to bring up the modal window with datatable. You will see that what is selected is not what was chosen by the user.

Any help is appreciated.

Thanks,

-Rhon

Replies

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Ouch - that sounds like a bug in Firefox I'm afraid. I can only presume that Firefox is remembering which checkboxes are checked by position and is then applying them before the DOM ready event has fired (i.e. when the DataTable is in it's raw HTML state). It sounds like Safari will be applying the remembered form values after the DataTable has been initialised.

    So two options I can think of (other than submitting a bug report to Mozilla and waiting for a patch :-) ):

    1. Use fnDestroy in window.unload for Firefox, which will destroy the table and put it back into it's original state. But this will slow down the browser's navigation and isn't a brilliant solution.

    2. Use a cookie to store what checkboxes are checked, then after the table has been initialised you could run through the checkboxes and ensure that the ones that should be checked, are checked. It's a little bit more work, but sounds like a better solution to me.

    Regards,
    Allan
  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    Allen,

    Do you have any sample code to achieve the cookie option?

    Thanks,

    -Rhon
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    I'm afraid not - it would need to be custom code, and probably slightly difference in each instance anyway. A live event on the checkboxes which will detect the state change and then store that in an array which gets serialised into a cookie would be the basic principle.

    Allan
  • brazbraz Posts: 12Questions: 0Answers: 0
    check this discussion: http://datatables.net/forums/comments.php?DiscussionID=301
  • jkojkojkojko Posts: 3Questions: 0Answers: 0
    I find a related problem with checkboxes and Firefox and IE on your sample page (FF:3.6.16)

    http://www.datatables.net/examples/api/form.html

    It is not possible to sort the checkbox-column

    a bug?
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Yes it is possible: http://datatables.net/examples/plug-ins/dom_sort.html .

    Allan
  • jkojkojkojko Posts: 3Questions: 0Answers: 0
    Allan, thanks for the quick response.

    You are right it works here http://datatables.net/examples/plug-ins/dom_sort.html .

    but I am also right, it does not work here: http://www.datatables.net/examples/api/form.html

    but i see that there is a solution for my problem

    kind regards!

    Joerg
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Correct - the form example you like to doesn't have the DOM sorting extensions that the other example does (for reasons of trying to keep each individual example reasonably simple). Combining the two will hopefully give you what you are looking for.

    Allan
This discussion has been closed.