Datatables 2.0.0 - "Loading ..." message doesn't show custom message if no records on first load

Datatables 2.0.0 - "Loading ..." message doesn't show custom message if no records on first load

jzohrabjzohrab Posts: 20Questions: 1Answers: 0

Hello all, I have a simple table that shows a custom message if it's empty:

    book_listing_table = $('#booktable').DataTable({
      language: {
            emptyTable: "No books available. <a href='/book/new'>Create one?</a>"
    },
    ...
      ajax: {
        url: "/book/datatables/active",
        type: "POST",
        dataType: "json"
      },
     ...

On initial page load, my ajax call returned this (which was valid):

{
  "data": [],
  "recordsFiltered": 0,
  "recordsTotal": 0
}

If the ajax call returns no data, when I first go to the page, the "Loading ..." message stays stuck, i.e. the "no books available" message is not shown.

If I change the search filter, e.g. add an "x" to the filter, the message "No books available. Create one?" is shown as expected, and the same data is returned from the ajax call.

Prior to the upgrade to 2.0.0, the "No books available. Create one?" message was shown on initial page load. I can't see anything obvious I've missed in the configuration. Hopefully someone can point me in the right direction.

Thank you very much! Jeff

Replies

  • allanallan Posts: 61,765Questions: 1Answers: 10,111 Site admin

    Hi Jeff,

    Apologies for the error. I've actually committed a fix for this issue already and it will be in 2.0.1 which will drop soon (by Tuesday at least). The fix is in the nightly builds if you want to use it immediately.

    Allan

  • jzohrabjzohrab Posts: 20Questions: 1Answers: 0

    Hi @allan -- thank you very much, as always. Let me know if there is a better place to report issues, managing a public forum like this can become overwhelming. Cheers!

  • allanallan Posts: 61,765Questions: 1Answers: 10,111 Site admin

    This is the best please.

    managing a public forum like this can become overwhelming

    Yup! But if it wasn't here, it would just be overwhelming somewhere else :)

    Allan

  • dqminhdqminh Posts: 1Questions: 0Answers: 0

    Just updated to 2.0.0 and seen this behavior today. Thank @allan for quick action.

  • jzohrabjzohrab Posts: 20Questions: 1Answers: 0

    I updated to 2.0.1 today and the message now appears as expected. Thank you for the fix! I believe this issue can be closed. Regards, jz

Sign In or Register to comment.