DataTables / Plugins

Plug-ins for DataTables
Other
1.04k stars 1.74k forks source link

Input pagination doesn't show when retrieving data via ajax #106

Open gdau opened 9 years ago

gdau commented 9 years ago

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

DataTables commented 9 years ago

Are you using the latest input paging plug-in from this repo? Sounds like a bug to me.

gdau commented 9 years ago

Latest version, yes. The previous version doesn't seem to support hiding itself if then total number of pages <= 1 which is probably where this bug was introduced.

DataTables commented 9 years ago

@Anderezekial - Do you have any thoughts on this. You've effectively become the maintainer of that plug-in with your recent commits. Congrats ;-)

gdau commented 9 years ago

Ha!

The quick fix for me was just to always show it after rendering as in my snippet above - can't see it doing any damage - I am happy to submit that as a PR?

Gav

Anderezekial commented 9 years ago

Looks good to me. Makes sense for AJAX calls to need this.

On Thu, Oct 9, 2014 at 7:38 AM, gdau notifications@github.com wrote:

Ha!

The quick fix for me was just to always show it after rendering as in my snippet above - can't see it doing any damage - I am happy to submit that as a PR?

Gav

— Reply to this email directly or view it on GitHub https://github.com/DataTables/Plugins/issues/106#issuecomment-58519014.

xrCKN8km6s commented 9 years ago

Hi all,

Any progress with this? The issue has not been fixed yet in 1.10.7.