Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Ajax and DataObjectSet pagination

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

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

Page: 1
Go to End
Author Topic: 1757 Views
  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Ajax and DataObjectSet pagination Link to this post

    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...

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Ajax and DataObjectSet pagination Link to this post

    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 http://code.google.com/p/silverstripe-podcast-module/source/browse/trunk

    Let me know if that answers your question

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Ajax and DataObjectSet pagination Link to this post

    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

    1757 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.