All Projects → vojtech-dobes → Nette.ajax.js

vojtech-dobes / Nette.ajax.js

Licence: mit
Flexible AJAX for Nette Framework. Supports snippets, redirects etc.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nette.ajax.js

Tracy
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
Stars: ✭ 1,345 (+796.67%)
Mutual labels:  nette, nette-framework, ajax
application
✨ Extra contrib to nette/application (@nette)
Stars: ✭ 23 (-84.67%)
Mutual labels:  nette, nette-framework, ajax
Naja
Modern AJAX library for Nette Framework
Stars: ✭ 86 (-42.67%)
Mutual labels:  nette, nette-framework, ajax
Safe Stream
SafeStream: atomic and safe manipulation with files via native PHP functions.
Stars: ✭ 101 (-32.67%)
Mutual labels:  nette, nette-framework
Formchimp
A customizable MailChimp ajax plugin for jQuery
Stars: ✭ 98 (-34.67%)
Mutual labels:  ajax, jquery
Nette
👪 METAPACKAGE for Nette Framework components
Stars: ✭ 1,356 (+804%)
Mutual labels:  nette, nette-framework
Mydailylearn
🚀 Important commands, Code Snippets, Basics on different topics learning daily 🎉!
Stars: ✭ 87 (-42%)
Mutual labels:  ajax, jquery
Component Model
⚛ Component model foundation for Nette.
Stars: ✭ 117 (-22%)
Mutual labels:  nette, nette-framework
Fileuploader
Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
Stars: ✭ 111 (-26%)
Mutual labels:  ajax, jquery
Jquery.initialize
jQuery plugin for dynamically created elements initialization (it was nice few years ago, in 2019+ consider react or sth instead of jQuery)
Stars: ✭ 150 (+0%)
Mutual labels:  ajax, jquery
Klik Socialmediawebsite
Complete PHP-based Login/Registration system, Profile system, Chat room, Forum system and Blog/Polls/Event Management System.
Stars: ✭ 129 (-14%)
Mutual labels:  ajax, jquery
Tokenizer
Source code tokenizer
Stars: ✭ 119 (-20.67%)
Mutual labels:  nette, nette-framework
Webapiclientgen
Strongly Typed Client API Generators generate strongly typed client APIs in C# .NET and in TypeScript for jQuery and Angular 2+ from ASP.NET Web API and .NET Core Web API
Stars: ✭ 134 (-10.67%)
Mutual labels:  ajax, jquery
Bpage
Based on bootstrap style, static page jump can also be asynchronous page processing pagination plugin
Stars: ✭ 96 (-36%)
Mutual labels:  ajax, jquery
Docs
📖 The Nette documentation
Stars: ✭ 99 (-34%)
Mutual labels:  nette, nette-framework
Jeeplatform
一款企业信息化开发基础平台,拟集成OA(办公自动化)、CMS(内容管理系统)等企业系统的通用业务功能 JeePlatform项目是一款以SpringBoot为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区
Stars: ✭ 1,285 (+756.67%)
Mutual labels:  ajax, jquery
Nukeviet
NukeViet CMS is multi Content Management System. NukeViet CMS is the 1st open source content management system in Vietnam. NukeViet was awarded the Vietnam Talent 2011, the Ministry of Education and Training Vietnam officially encouraged to use.
Stars: ✭ 113 (-24.67%)
Mutual labels:  ajax, jquery
Php Generator
🐘 Generates neat PHP code for you. Supports new PHP 8.0 features.
Stars: ✭ 1,264 (+742.67%)
Mutual labels:  nette, nette-framework
Jquery Confirm
A multipurpose plugin for alert, confirm & dialog, with extended features.
Stars: ✭ 1,776 (+1084%)
Mutual labels:  ajax, jquery
Django Crud Ajax Login Register Fileupload
Django Crud, Django Crud Application, Django ajax CRUD,Django Boilerplate application, Django Register, Django Login,Django fileupload, CRUD, Bootstrap, AJAX, sample App
Stars: ✭ 118 (-21.33%)
Mutual labels:  ajax, jquery

For Nette Framework

Flexible utility script for AJAX. Supports snippets, redirects etc.

License

MIT

Dependencies

jQuery 1.7

Installation

  1. Copy nette.ajax.js to your directory with Javascript files (you can use Bower for this).
  2. Link the file in your templates (usually in app/@layout.latte, after jQuery!).
  3. 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:

$.nette.ext('name', {
    event1: function () {
    },
    event2: ...
}, {
    // ... shared context (this) of all callbacks
});

First argument is name. It's optional.

Second argument should be hash of callbacks with keys corresponding to names of events. These events are available:

name arguments description
init Called just once during $.nette.init(); call.
load requestHandler Should contain ajaxification. requestHandler can be bound to UI events to initiate AJAX request.
before jqXHR, settings Called immediatelly before AJAX request execution. If FALSE is returned, request won't start.
start jqXHR, settings Called immediatelly after start of AJAX request.
success payload, status, jqXHR, settings Called after successful completion of AJAX request. Equivalent to $.ajax( ... ).done( ....
complete jqXHR, status, settings Called after every AJAX request completion. Equivalent to $.ajax( ... ).always( ....
error jqXHR, status, error, settings Called in case of failure of AJAX request. Equivalent to $.ajax( ... ).fail( ....

Extension can be disabled:

$.nette.ext('name', null);

Extension can be configured. Its context can be acquired by:

var context = $.nette.ext('name');

Default extensions

name description
validation Limits the ajaxification to clicks/submits without Ctrl, Alt or Shift key, local links and valid form submits.
forms Adds support for submitting forms with all data, name of clicked button and coordinates of click in [type=image] inputs.
snippets Updates DOM by snippets array in response (default Nette handling of Latte snippets).
redirect Executes redirect to different URL (when $this->redirect() is called in presener). Can be replaced by history extension.
unique Keeps only request running at the same moment.
abort Allows user to abort running request by pressing Escape.
init Default ajaxification.

Useful tricks

All these special features expect all default extensions to be on.

data-ajax-off

Link or any other ajaxified element can have custom data attribute data-ajax-off. It contains names of extensions, that should be deactivated for Ajax request fired on element.

<a n:href="do!" class="ajax" data-ajax-off="snippets">

You can also use it in $.nette.ajax(). Like this:

$.nette.ajax({
	url: ...,
	off: ['snippets']
});

data-ajax-pass (in validation extension)

Ajaxification of element ensures, that e.preventDefault() will be called. This attribute can prevent it, if you need more callbacks to be fired.

data-ajax-append (in snippets extension)

New content of snippet with this attribute won't replace the old content, but it will rather be appended to it.

data-ajax-prepend (in snippets extension)

New content of snippet with this attribute won't replace the old content, but it will rather be prepended to it.

data-ajax-validate (in validation extension)

Click on link or submittion of form is validated on various conditions. You can switch any of them:

<a n:href="do!" class="ajax" data-ajax-validate='{"keys":false}'>

And as in case of data-ajax-off, you can pass it right into $.nette.ajax().

$.nette.ajax({
	url: ...,
	validate: {
		keys: false
	}
});

This means that clicking link with Ctrl will not open new tab, but will ajaxify request.

Dependency on other extension

In event callbacks, you can call this.ext() to get context of other extension. If you add true as second argument, script will fail if that extension won't be available.

$.nette.ext({
	success: function (payload) {
		var snippets = this.ext('snippets', true);
		...
	}
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].