hypejunction/elgg-ajax-form
Composer 安装命令:
composer require hypejunction/elgg-ajax-form
包简介
Handling form submissions with promises
README 文档
README
Dealing with form submission using jQuery is hell, especially when you have to bind multiple handlers that depend on each other. This plugin provides a module that can be used to queue promise-based handlers.
var Form = require('ajax/Form'); var form = new Form('.my-form'); var Ajax = require('elgg/Ajax'); form.onSubmit(function(resolve, reject) { // execute a long running script, e.g. validate fields via ajax var ajax = new Ajax(); ajax.post('somewhere').done(resolve).fail(reject); }) form.onSubmit(function(resolve, reject) { console.log('hello'); resolve(); }); // By default, once all promises are resolved, the form will be submitted via ajax, // and the user will be forwarded to the URL specified by the response // You can however register custom success callbacks to prevent redirection form.onSuccess(function(data) { console.log(data); require('elgg/lightbox', function(lightbox) { lightbox.close(); }); $('.my-list').refresh(); }); // You can also add your own error handler form.onError(function(error) { console.log(error); });
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2019-08-01