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
You have to use ajax call for every pagination link and need to send the page arguments.
Ajax pagination
Hi pflame,
please explain how to call ajax pagination in own custom module
ajax pagination
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
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);
});
}
}
// 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
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
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
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.
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
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
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