closing Jquery Mobile dialogs triggers a re-init warning from dataTables

closing Jquery Mobile dialogs triggers a re-init warning from dataTables

frequentfrequent Posts: 23Questions: 0Answers: 0
edited February 2012 in General
I'm using dataTables on a Jquery Mobile site.

Jquery Mobile changes select inputs to a full-page dialog page, which open when you click on the select button (example here: http://jquerymobile.com/demos/1.0.1/docs/forms/selects/custom.html - "Alabama select").

If I have a page with dataTable and try to close one of these open dialog-subpage I get the following dataTables warning:

DataTables warning (table id = 'DataTables_Table_0'): Cannot reinitialise DataTable. To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy

I think this is because opening and closing dialogs triggers hashChange events, which JQM blocks. My question would be whether it's possible to override this warning, because as long as the user stays within the DOM, the table does not have to be reinitialized.

Thanks for any pointers & awesome product!

Frequent

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited February 2012
    Just set bRetrieve: true in your initialisation :-). Its a bit odd that the initialiser is called twice because of an input element, but, that will at least stop the warning.

    Allan
  • frequentfrequent Posts: 23Questions: 0Answers: 0
    Cool! Worked and I'm "alert-free". Thank you very much!

    If you are ever thinking about adding a themeable Jquery Mobile UI next to the Jquery UI (with responsive table layout) for mobile devices let me know. I'm sort of half-way through with it :-)
  • pclemonspclemons Posts: 3Questions: 0Answers: 0
    frequent, you said (way back in February) that you were sort-of half-way through with it. I'd love to take a look at what you've got. My email is pclemons@netiq.com. Thanks!
  • frequentfrequent Posts: 23Questions: 0Answers: 0
    pclemons, I'm still working on it... actually sitting on it right now for a project I'm far behind and due end of the month. Afterwards I hopefully have time to fill my Github repo. In the meantime you can try this: http://stackoverflow.com/questions/10386821/mobile-data-entry-mobile-friendly-datagrid/10439160#10439160, where I posted a quick rundown of how to set it up along with a link to a small demo. I hope to have more time come August.
  • FBeyhumFBeyhum Posts: 1Questions: 0Answers: 0
    Frequent,
    Just a note: I tested your demo, and it wrks but not in IE. can you check it?
    it would be nice to have datatables work properly in jquery mobile. how much more time before you finish your work?
  • KimballKimball Posts: 2Questions: 0Answers: 0
    edited February 2013
    Thanks!
    I'm using DataTable with jQueryMobile. Was get the same "Cannot reinitialise DataTable" error when returning to the page that has the DataTable.

    "bRetrieve": true did the trick.
  • sinceresincere Posts: 7Questions: 0Answers: 0
    Hi Allan, I had not the above but a similar issue with my datatables implementation and while looking for a solution, I obviously started here. The bRetrieve thing did the trick for me during the table initialization but I didn't quite get what it does. In my case, I had a menu button which when clicked loaded the datatable.

    The issue was that on double clicking the menu button, I got a JS alert saying Datatables warning.... reading the bdestroy documentation.

    Do you mind giving a short explanation. Thanks
This discussion has been closed.