Looking for a new maintainer: The current maintainer is no longer able to support the module. Please see #2860726: Seeking new maintainer for Ajax Pages for details.

This module goes to great lengths to implement generic-purpose loading of the site's pages via Ajax, with the possibility to create region(s) that will be exempt from such loading. A concrete example of using this functionality is putting a persistent audio player on your website that would continue playing as the user browses the pages.

Demo

Features

  • Works inobtrusively out of the box
  • Requires only minimal theme modifications
  • Browser address bar updating using HTML5's history.pushState()
  • Full page reloading (page_top, page and page_bottom regions)
  • Transparently ajaxifies forms, including GET ones
  • Handles redirects
  • Loads additional CSS and JS files as required
  • JS/CSS preprocessors and aggregation friendly
  • Ajax requests are GET and fully cacheable (also with Boost!)

Known issues

Enabling Boost caching

Boost currently doesn't support the application/json content type that Ajax pages uses for its responses. This is addressed by #1219484: Types application/xml and application/json not supported (support for services module).

Re-initializing third-party scripts

Ajax pages re-applies all Drupal behaviors to the newly inserted content. However, some scripts such as Twitter widget initialization or Facebook's FBML JavaScript aren't Drupal behaviors and need to be told to re-run.

Ajax pages triggers the $(window).load() event after inserting new content, so this can be done as follows in a custom module:

$(window).load(function () {
  if (typeof twttr !== 'undefined') {
    twttr.widgets.load();
  }
  if (typeof FB !== 'undefined') {
    FB.XFBML.parse();
  }
});

Wrong JS settings merging in ajax_render()

Due to a bug in core, the JS settings array produced by ajax_render() may differ from the one produced by drupal_get_js(), which may break some of the page functionality. It is recommended to install the patch from #1983096: Bring JS settings merging in ajax_render() in line with drupal_get_js().

Project information

Releases