Adding some jQuery sugar to frontal

I’ve just pushed a new feature and some minor tweaks to the frontal project on github.

jQuery chaining

With the new jQuery module included (frontal.jquery.js) it’s now possible to use frontal rules with jQuery’s fluent interface.

$.frontal('/some/path').addClass('something');

If the frontal rule passed to $.frontal matches the page location a jQuery object containing the page element is returned; should the rule fail to match an empty jQuery object is returned.

.data() now accepts key value pairs

Instead of just getting and setting one big chuck of data it’s now possible to store values and retrieve them with keys.

Setting

$frn.data('key', 'value').data('this', 'that');

Getting

$frn.data('key') // 'value'
$frn.data('this'); // 'that'

Domain is removed with .location()

When setting the page location with .location() any domain and protocol that might be preceding the path is automatically removed. This makes it easier to bind ajaxy functionality to links and handle the responses with frontal (particularly in IE which includes the domain when accessing the href attribute — dammit).

I’m getting to grips with how I think frontal can be used now so I’m going to start producing some proper API documentation.

Head over to the github repo for the funsies.