A year ago, we published a library for doing declarative AJAX, called bootstrap-ajax. Recently, we renamed it to [[https://github.com/eldarion/eldarion-ajax|eldarion-ajax]].


The reasoning behind the rename was that it was a fairly opinionated library that does AJAX the way Eldarion does it on most of our projects and had very little to do with Twitter Bootstrap. In fact, the only part that Twitter Bootstrap played in the library is inspiring the markup driven approach to plugins.

With this new release, there are two big improvements:

  • automated test suite testing the library against the 4 most recent versions of jQuery
  • while still opinionated out of the box, it's now possible to easily extend it to work in very custom ways

In addition, a number of bug fixes were made closing quite a few GitHub issues.

One common request that would come in [[https://github.com/eldarion/eldarion-ajax/pull/32|from time]] to [[https://github.com/eldarion/eldarion-ajax/pull/41|time]] was asking to add a new type of handler. This was not sustainable to keep adding new handlers but there was no way to give site developers the way to just extend and easily add their own. Now, this is as easy as writing your own module and including it after the {{{eldarion-ajax.min.js}}} or {{{eldarion-ajax-core.js}}} (if you didn't want any of the handlers that ship with the minified version.

Here is an example of adding a handler to remove the closest parent. eldarion-ajax ships with a handler to remove an explicit selector but not a relative one.

{{{ #!code javascript (function ($) { 'use strict';

var Handlers = function () {}; Handlers.prototype.removeClosest = function(e, $el, data) { $el.closest($el.data('remove-closest')).remove(); }; $(function () { $(document).on( 'eldarion-ajax:success', '[data-remove-closest]', Handlers.prototype.removeClosest ); });

}(window.jQuery)); }}}

The [[https://github.com/eldarion/eldarion-ajax-demo|open source demo project]] has been updated and is online at [[http://uk013.gondor.co/|http://uk013.gondor.co/]] to see a sampling of a subset of the functionality found within the library.