Skip to content

Instantly share code, notes, and snippets.

@mohit-rocks
Created October 11, 2014 14:07
Show Gist options
  • Save mohit-rocks/bc2cb89581868528c527 to your computer and use it in GitHub Desktop.
Save mohit-rocks/bc2cb89581868528c527 to your computer and use it in GitHub Desktop.
Infinite pager without infinitescroll.js [Drupal] [Apache solr page] Ref : https://www.drupal.org/node/1473558#comment-8597229
/**
* Js file to add load more button on the search result page.
*/
(function ($) {
Drupal.behaviors.loadMoreAjax = {
attach: function (context, settings) {
$('.load-more-ajax', context).click(function () {
var nextPage = $('.pager .pager__item--next a').attr('href');
var lastPage = $('.pager .pager__item--last a').attr('href');
$.get(nextPage, function (data) {
$(data).find('.apachesolr_search-results').insertBefore($('.pager'));
$('.pager').remove();
if (nextPage == lastPage) {
$('.load-more-ajax').remove();
}
else {
$(data).find('.pager').appendTo($('.pager'));
Drupal.attachBehaviors($('.apachesolr_search-results'));
}
});
});
$('.pane-apachesolr-result .pager').hide();
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment