开发者

More/Pagination implementation like on Facebook.com

开发者 https://www.devze.com 2023-03-10 14:42 出处:网络
I\'m currently working on a site and I would like to barrow the technique from Facebook on how the \'pagination\' or \'view more\' works.I think I have it sorted out but I\'m just asking if开发者_JAVA

I'm currently working on a site and I would like to barrow the technique from Facebook on how the 'pagination' or 'view more' works. I think I have it sorted out but I'm just asking if开发者_JAVA百科 this is the prefered approach or if I'm way off base.

  1. I'd have a More button that when the user hovered or clicked upon it I'd fire off an ajax request.
  2. The ajax request would pass two variables the limit and the current item (just like a normal pagination would work) and grab the results from the database and render them as necessary for the feed/etc.
  3. I'd use jQuery's append to add an anchor link here so i could jump to the spot where the last post was. Then I'd append the results from the ajax request to the bottom of my feed/etc.
  4. Fire the link to move the screen to the anchor tag and call it a day.

Anything I'm missing? Any flaws that you see that you could give me a heads up on... I'm currently using primarily PHP, MySQL, and jQuery as my weapons of attack.

Any assistance would be appreciated.


I have implemented this with similar idea.

When you click the "more" button,

  1. remove that button.

  2. Request with $.getJSON a page to get next page data.

  3. append those to the content-page-div.

  4. append the removed "more" button to the end.

0

精彩评论

暂无评论...
验证码 换一张
取 消