DataTables / DataTables/Plugins

Input pagination doesn't show when retrieving data via ajax

Open
#106 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Hi!

Just upgrading to latest version of datatables and the plugins and noticed that when the number of pages is zero (when the table is initialised), the pagination helper is hidden. When the ajax call returns, the fnUpdate is called and the pagination controls are rebuilt but the outer pagination element is not shown again.

I have fixed it by adding:

$(an).show();

after the loop is rendered in "fnUpdate". So it becomes:

            /* Loop over each instance of the pager */
            for (var i = 0, iLen = an.length ; i < iLen ; i++)
            {
                var spans = an[i].getElementsByTagName('span');
                var inputs = an[i].getElementsByTagName('input');
                spans[3].innerHTML = " of " + iPages;
                inputs[0].value = iCurrentPage;
            }

            $(an).show();

Is this acceptable or did I perhaps did something wrong?

Cheers!

Gav

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the pagination plug-in's fnUpdate function and reproduce initialization with zero pages followed by an AJAX response. The work is done when the rebuilt pagination controls and their outer pagination element are visible after the update.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.