What is modAjaxify

 

modAjaxify is mainly a jquery plugin which is strongly coupled with MODX Revolution. Nevertheless it can be used on its own as a plain jquery plugin.

 

It automatically parses any (or selected ones) content links and ajaxifies them without destroying them which makes the addon SEO friendly. That means that if the link is clicked the page will not be reloaded but the fetched content of the link will be placed on a specific container as configured by the developer. Although if you open the link in a new tab it will load normally.

 

The plugin has many options to control where and what to ajaxify and also events that signify the start/progress/end of loading which is very useful for creating loaders.

Another useful feature of the plugin is that is able to preload any content images before rendering the content in the target container.

 

This addon can be started with zero configuration just by placing the [ [ $ ajaxifyInit ] ] in the head of the template.

 

Dependencies

jquery

jquery.history.js

preloadjs-0.6.1.min.js

 

If you already loading these libraries then you should remove them from [ [ $ ajaxifyInit ] ]

 

modAjaxify Documentation

The configuration of the addon is controlled through the jquery plugin shadowUrls.

An initial configuration can be found in the chunk ajaxifyInit.

 

What it does:

 

Get Started

This addon can be started with zero configuration just by placing the [ [ $ ajaxifyInit ] ] in the head of the template.

API

shadowUrls properties

shadowUrls callbacks

Params:

Params:

 

          $(‘custom_container’).html(processed_responce).shadowlinks();

Params:

 

Params:

Params:

Params:

Params:

 

HTML properties

The plugin make use of 3 html properties.

 

Eg.<a title=”Some title” context=”some_id” href=”som_url”>Test</a>

 

The above example will load the content from some_url and will place it inside an element having this ID

 

Note: The MODX plugin will prune and transmit only the desired element (which has the context ID) from the content (as long as it exists) to boost performance.

 

Eg.<img src-2000=”big.jpg” src-1000=”medium.jpg” src=”small.jpg” />

 

This means that any device with screen higher than 1000px width will load medium.jpg, if higher than 2000 will load big.jpg and if is smaller than 1000 will load small small.jpg

 

Example of usage as provided in the ajaxifyInit chunk

 

$.shadowUrls({

          'targetSelectorId': 'content',

          'menuSelector': '.menu',

          'activeClass': 'active',

          'menuChildrenSelector': '.menuoption',

          'noAjaxClass': '.noajax',

          onSuccess: function (url, response) {

              $(this).fadeIn();

 

          },

          onRender: function (url, data) {

 

              $(this).html(data).shadowlinks();

 

          },

          onProgress: function (url, progress) {

              console.log("loading progress:" + progress);

 

          },

          beforeLoad: function (url) {

              $(this).fadeOut();

          }

      });