Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/filamentgroup/Ajax-Include-Pattern

An Ajax-Include Pattern for Modular Content
https://github.com/filamentgroup/Ajax-Include-Pattern

Last synced: 6 days ago
JSON representation

An Ajax-Include Pattern for Modular Content

Awesome Lists containing this project

README

        

## HijaxInclude with Forms

If you include `src/ajaxIncludeForms.js` (or `dist/ajaxIncludePlugins.js`) and `$(...).serialize()` is available, you can also use HijaxInclude with forms to hijack the submit event.

### HTML




### JavaScript

$( "form[data-interaction]" ).bind( "submit", function() {
$( this ).removeAttr( "data-interaction" ).ajaxInclude();
return false;
});

## Header Hooks

If you include `src/ajaxIncludeHeaderHooks.js` (or `dist/ajaxIncludePlugins.js`), you can execute JavaScript when a specific HTTP Header is returned to the XHR object.

### JavaScript

// Example: Redirect to the url returned by the
// X-AjaxInclude-Redirect header.
$( el ).ajaxInclude({
headerHooks: {
'X-AjaxInclude-Redirect': function( url ) {
window.location.href = url;
}
}
});