For Nette Framework

License

Dependencies

Installation

Copy nette.ajax.js to your directory with Javascript files (you can use Bower for this).

Link the file in your templates (usually in app/@layout.latte, after jQuery!).

Put somewhere the initialization routine:

$(function () {
$.nette.init();
});

Usage

By defaults all links and forms with CSS class ajax will be instantly ajaxified. Behavior can be altered in configuration of init extension. Object returned by call var init = $.nette.ext('init'); has these props:

name

default value

description

linkSelector

a.ajax

CSS selector for links

formSelector

form.ajax

CSS selector for forms

buttonSelector

input.ajax[type="submit"], input.ajax[type="image"]

CSS selector for form elements responsible for submit

Ajaxification is bound to click (submit) event in nette namespace. Ajaxification of specific link can be canceled with code like this (while other callbacks will remain):

$('a.no-ajax').off('click.nette');

Or even simpler:

$('a.no-ajax').netteAjaxOff();

Extensions

Ajaxification envelopes standard $.ajax() call and extends it with several events, that can be hooked with custom callbacks. Set of associated callbacks is called extension. Snippets processing, ability to cancel running request by Escape... all this functionality is implemented in form of extensions. Registration of extension looks like this: