Custom Ajax Pagination

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by sarath.verve on December 24, 2011 at 4:39am

Hi..

I am working on a custom search module which gives the result in ajax. My return is " drupal_json(array('sample'=>$output)); ". $output contains my html with the search result along with my pagination function. My first page is loading in ajax which is fine for me. But when I click 2 page its redirecting to the ajax path along with the arguments " ?page=1&js=1" . I want this page also loads in the same page in ajax ( with out reloading ) . How can I bring pagination also in the ajax format?

Thanks for all helps...!

Comments

You have to use ajax call for

Posted by pflame on December 28, 2011 at 8:22am

You have to use ajax call for every pagination link and need to send the page arguments.

Ajax pagination

Posted by muruganantham on February 1, 2012 at 5:46am

Hi pflame,
please explain how to call ajax pagination in own custom module

ajax pagination

Posted by jaffaralia on February 1, 2012 at 9:16am

Hi,
You have to call ajax pagination by using the following code

Drupal.behaviors.searchblock = function (context) {
$('.search-basket-block ul.pager li a').click(search_result_pager);
}
// Filter Results Paginations
function search_result_pager() {
thisLink = $(this);
thisUrl = this.href;
target = $("#search-box-block-search-results");
$.ajax({
url: thisUrl,
type: "GET",
success: function(data) {
$('#search-box-block-search-results').html(data);
Drupal.attachBehaviors("#search-box-block-search-results");
}
});
return false;
}

Thanks,
A. Jaffar ali

Ajax Pagination in Drupal 7

Posted by freebug on September 3, 2012 at 2:36pm

Thanks jaffaralia,

Took help form your code to write the ajax pagination and table sort. Had a table loaded via ctools. But its sortable table header and the pagers were not working.

Used the code below to get both the table headers and the pagers working.

Drupal.behaviors.hvcb_utilities = {
attach: function (context, settings){
var selector = '.hvcb-utilities-content-replace';
//Handle Ajax calls on pager links
jQuery(selector + ' ul.pager li a',context).live('click', function(e){
e.preventDefault();
hvcb_ajax_links(selector, this);
});

//Handle Ajax calls on table header links
jQuery(selector + ' thead tr a',context).live('click', function(e){
 e.preventDefault();
 hvcb_ajax_links(selector, this);
});
// Add/remove "active" class to the top buttons
jQuery('#hvcb-utilities-user-usage .action-buttons a').click(function(e){
 jQuery('#hvcb-utilities-user-usage .action-buttons').removeClass('active');
 jQuery('#hvcb-utilities-user-usage .action-buttons a').removeClass('active');
 jQuery(this).parents('.action-buttons').addClass('active');
 jQuery(this).addClass('active');
});

}
}

// Replace ajax links
function hvcb_ajax_links(selector, el) {
jQuery.ajax({
url: el.href,
type: "GET",
dataType: "json",
beforeSend: function(jqXHR, settings){
//Mimic the default AJAX behaviour
jQuery(el).append('

');
},
success: function(data) {
jQuery(selector).html(data[1].data);
},
error: function(e){
alert(e.statusText);
var ajaxprocess = selector + " .ajax-progress-throbber";
jQuery(ajaxprocess).remove();
}
});
}

Custom Ajax Pagination

Posted by sumit_drupal on February 7, 2012 at 10:26am

Hi , I want to implement ajax pagination.Actually i have content type story in which i want to fetch similar stories title from the database while entrying node title rendering with node title is fine but no luck with the pagination i dont want to reload the whole page.Please advise me on this.

Use Views

Posted by parimal.jariwala on February 7, 2012 at 11:04am

You can use views module and create view to display stories. You can add filters and fetch stories.
Views provides default pagination with/without ajax both. You just need to configure it at the time of view creation.

-
Parimal

Using Node Title

Posted by sumit_drupal on February 7, 2012 at 1:28pm

Thanks for the reply.No luck using views actually what i have to do is to fetching similar stories when i input title.I am using a ajax call using onkeyup event in which i am calling a custom module function which returns similar titles which will be display at the bottom of the story form.In this i want to use ajax pagination because i dont want to reload a page.
If i use views than the problem will occur at the time of filter because i want to render at the time of inputting node title so i want to filter my result using node title.
Any help would be appreciable.

Help regaring to ajax paging.

Posted by Hammad.Chishti on April 26, 2012 at 11:43pm

Hello guys,

I am newbie in drupal and wants some help in custom ajax pagination.
I have a list of nodes and I have to make three tabs like quick tabs and make pagination of each tab listing, before starts working on it I was tried to use views and make listing with pager but unfortunately there is a bug or conflict between quick tabs and views pager.
So I am trying to make a module and use my own paging. So far I made the listing but cant understand how to add ajax pagination.
I couldn't find any clean example of ajax custom pager,
Please if you share anything that would be great.

Thanks
Hammad

Use Ajax pagination in views

Posted by y.anvesh on April 27, 2012 at 12:30pm

Hi Hammad,

Views provide pagination and ajax loading by default.

No need of writing new module for it.

You can enable 'Use ajax' in the view.

Make sure you 'override' the view properly and check other settings.

Flush your cache once or twice(in D7) to see proper functionality.

--
Anvesh.Y

Hi Anvesh

Posted by Hammad.Chishti on April 28, 2012 at 11:03am

Thanks for reply, I think your right because if i do it with my own module may be it will take long time, so i will try it by views again with your instructions keep in mind.

Thanks

Washington, DC Drupalers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /