Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Ajax and DataObjectSet pagination

Go to End

3 Posts   2214 Views


Forum Moderator, 1391 Posts

14 July 2010 at 3:57am

I'm building a site where I'm showing a selection of DataObjects on a page, using the default DataObjectSet Pagination. This works fine, but now I want to use Ajax to load the next batch of objects into a wrapper div, without having to reload the entire page.

What I'm doing is have a jQuery click event load the pagination link into the wrapper div, adding an extra urlsegment, athat calls my Page's AjaxPagination() action. So:

myURL/?start=9&... becomes /myURL/AjaxPagination/?start=9&...

Normal pagination would still work when javascript is disabled, so this would work splendidly, if only the DataObjectSet pagination wouldn't use HTTP::setGetVar() to compose the links. Now the extra url bit is added permanently to the paginationlinks. If the DataObjectSet would just return the querystring and let me add the page Link() manually this would be such an elegant and extremely simple solution...

Has anyone done this before or have ave any ideas on this? It would be much appreciated...


Community Member, 215 Posts

14 July 2010 at 9:56pm

Hey yea I've done this before, I put it in the podcast module so you might want to have a look at the JavaScript file and the getOrderedMessages function in PodcastPage.php

The module is here

Let me know if that answers your question :)


Forum Moderator, 1391 Posts

15 July 2010 at 11:10pm

I (stupidly :-( ) never even checked if Director::is_ajax() would work, since it said either use prototype or add some ajax header manually. I was convinced 'it' couldn't know about me doing some jQuery load... Still feels like some sort of magic that it does actually see me doing it.

Thanks Howard, for pointing me in the right direction :-)