Created
October 11, 2014 14:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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