Best Practices for Pagination (morenation)
Has anybody built a good morenation script for a list view?
By morenation I mean a facebook style where the next page is attached to the end of the list rather than pagination where you would go to the next page.
Right now, I have a list view and added a li at the end with my more link. This is my current code
- $('.more a').live('click', function(){
- Mobile.showIndicator();
- var more = $(this);
- var list = more.closest('ul,ol');
- var url = more.attr('href');
- console.log(url.indexOf('?'))
- var separator = url.indexOf('?') == -1 ? '?' : '&';
- more.jqmData('offset', parseInt( more.jqmData('offset') || more.jqmData('limit') ) );
- more.jqmData('limit', parseInt( more.jqmData('limit') ) );
- url += separator + 'offset=' + more.jqmData('offset') + '&limit=' + more.jqmData('limit') ;
- $.ajax({
- url: url,
- type: 'GET',
- success:function(data){
- list.find('.more').before(data);
- more.jqmData('offset', more.jqmData('offset') + more.jqmData('limit') )
- },
- error: function(){
- alert('Failed to load more data');
- },
- complete: function(){
- Mobile.hideIndicator();
- }
- });
- return false;
- });
It is still firing the default click action and creating and going to the new page.
What event do i need to bind to and prevent?
-rod