Форуми / Cotonti / Support / Ajax help.

lukgoh
#1 09.05.2013 13:55

Hey guys, trying to learn how to use ajax pagination properly following this: http://www.cotonti.com/docs/devel/ajax_helpers

However, when I use a div where I would like the list to load for each page of items it re-loads the whole page inside the div (so you see the whole page twice). Can anyone provide a little more information on what I could be doing wrong?

$pagenav = cot_pagenav('users', '&m=details&id=' .$id . '&c=' .$c. '&s=' .$s. '&w='.$w, $d, $totalitems,
        $cfg['plugin']['pagesbyuser']['pages_perpage'], 'd', '', true, 'pagesbyuser');

 

Trustmaster
#2 09.05.2013 17:34

Normally it should not include header/footer in the response if the request was sent with AJAX, regardless of what the pagination links look like. Does AJAX pagination work correctly in other areas?

May the Source be with you!
lukgoh
#3 09.05.2013 21:47

Sorry I wasn't very clear. It doesn't include the header or footer just repeats the page contents inside that div. 

Trustmaster
#4 10.05.2013 06:55

If you want to paginate a smaller block, you need to make an AJAX handler that would do it on the server side. AJAX helpers are rather primitive, they only paginate entire "content" area by default.

May the Source be with you!
lukgoh
#5 10.05.2013 09:40

When you say an AJAX handler, do you mean like this:

if (COT_AJAX)
{
    // AJAX-specific code here
}
else
{
    // Normal mode code here
}
 
// Common code here

 

Trustmaster
#6 10.05.2013 18:04

That is a correct example, though pagination above links to users?m=details&id=123 rather than a 3rd-party plugin, so it loads the output of the users module.

May the Source be with you!
lukgoh
#7 10.05.2013 18:16

Okay awesome, so I still hook into the users module so the tags work there?

Trustmaster
#8 10.05.2013 18:38

I think you should make an AJAX part in your plugin that would output the exact piece of HTML that you want and link to it instead, e.g.:

$pagenav = cot_pagenav('plug', 'r=pagesbyuser&id=' .$id . '&c=' .$c, $d, $totalitems, $cfg['plugin']['pagesbyuser']['pages_perpage'], 'd', '', true, 'pagesbyuser');

You might also want to replace 'd' with something else in the variable name to avoid conflicts with other plugins.

May the Source be with you!
lukgoh
#9 10.05.2013 18:50

Thank you Trustmaster I will give this a go!

Added 4 days later:

All I seem to get is: AJAX Error: objectobject ?

Added 2 hours later:

Is there a working example in the Cotonti Siena source code any where?


Відредаговано: lukgoh (14.05.2013 16:33, 10 років тому)
tensh
#10 16.05.2013 06:55

I think working example is in user's wall plugin... but i don't remember if it's siena or not. Also admin panel is pretty ajaxified, when you set category page limit to a lower value, category tree in admin panel gets paginated, as far as I remember.

Trustmaster
#11 16.05.2013 07:31

Have a look at userposts, it has a Siena version.

May the Source be with you!