0

I have disabled 'Use Ajax' because I don't want AJAX pagination. Unfortunately other Ajax functionality stopped working.

How to ajaxify View programmatically?

3
  • what exactly do you want ajaxified ? – rémy Mar 9 '16 at 20:58
  • I think you should add pager programmatically instead of ajaxify view. – Sumit Madan Mar 10 '16 at 5:55
  • @remy I have some custom ajax actions in my custom Views field. Besides this I'm using View refresh command. This command is working only when 'Use Ajax' option is enabled. With this option AJAX pagination will always work, but I don't want it to work, because it changes current page also - pager is switching to next or previous page after View refresh. I think without AJAX in pages this behaviour will be disabled. – Codium Mar 10 '16 at 8:50
2

@sumit madan's approach then is the best, leave your view ajaxified, and remove the paging, simplest seems to me by overwriting this method of the behavoir in your theme:

/**
 * Attach the ajax behavior to each link.
 */
Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
  this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
  .each(jQuery.proxy(this.attachPagerLinkAjax, this));
};

just make it an empty function (add this code in your theme behavoir)

Drupal.views.ajaxView.prototype.attachPagerAjax = function() {};

this function also needs to be overwirtten:

Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function() {};
3
  • Works, but not for first paging. Still ajaxified at first time. – Codium Mar 10 '16 at 11:35
  • 1
    OK, works. I need to set attachPagerLinkAjax = function () {}; also – Codium Mar 10 '16 at 11:43
  • alright, thanks for the feedback ! i updated the answer – rémy Mar 11 '16 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.