jPages icon indicating copy to clipboard operation
jPages copied to clipboard

Items count and AJAX problem

Open devmondo opened this issue 12 years ago • 6 comments

Hi, your plugin is one of the most amazing ones i have seen on net, but i am having big problem, it seems that your plugin works after the DOM elements are loaded, in other word it just hides the full number of elemnts and create paging numbers out of them, and in this way you cant set number of pages, what i mean is i want to do simple ajax request to get records from DB, where i have forexample 100 records and i want to return 10 per request, so i will naturally end up with 10 pages numbers with your plugin, but sadly it does not work :(

any hint i would totally appreciate it.

thanks in advanced.

devmondo avatar Apr 10 '12 10:04 devmondo

Hi,

Thanks :) This plugin offers only client side pagination, at least for now, maybe I'll add Ajax support in future releases. I believe you're trying to paginate all the records in your DB but you can only apply the plugin to items that are already loaded in the page, so it won't work.

But you can always re-apply the plugin after an Ajax call. Is that what you're trying to do?

luis-almeida avatar Apr 10 '12 13:04 luis-almeida

man, thanks alot for the answer, the problem is as you have said i am trying to paginate the database, and as you said the plugin will only paginate on client side, but what i want is to speed up things and only return 10 items per page, the only thing missing is to make the plugin able to inject number of pages based on total number of database records so each time you click on a page number a new request happens and you see the next batch of returned items.

devmondo avatar Apr 12 '12 01:04 devmondo

Hi,

You're right! It's something I want to add in the future since it would make the plugin much more flexible. But for now it's not possible since it's only a client side pagination plugin. Stay tuned for future releases cos when I have some time I'll add Ajax requests.

luis-almeida avatar Apr 13 '12 10:04 luis-almeida

thanks alot man, i cant wait really, i want to replace all the stupid once i have tried and replaced with this beauty.

all the best on your endeavor :)

devmondo avatar Apr 15 '12 17:04 devmondo

I'm facing the same problem here but i think the best solution is to "apply the plugin to items" as luis said. but surely we are waiting your Smart solution & Update.

Nilegfx avatar Apr 19 '12 13:04 Nilegfx

I know this is an old thread, but I found a solution at least for how I'm using jPages.

In my case, I am simply using ajax to return a list of items (in other words, I'm pulling my items at once and just want to paginate the results). I dug around some jQuery documentation and found out about ajaxSuccess. The following code works for me, and perhaps it could be helpful to someone else.

jQuery(document).ajaxSuccess(function(event, request, settings) {
    jQuery(function($) {
        addScript($this->filePaths->js_plugins.'jPages.min.js') ?>
            $("div.holder").jPages({
                containerID: "searchlist"
            });
    });
})

Code is taken from my Joomla script (hence the 'addScript' call) but the basic principle is simple. Upon ajax success embed jPages and then invoke it. Hopefully someone can tweak this and make it better. I'm just happy that I can keep using jPages. :)

Bratzilla avatar Apr 23 '13 04:04 Bratzilla