pessek/pessek_ajax 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pessek/pessek_ajax

Composer 安装命令:

composer require pessek/pessek_ajax

包简介

Ajax utilities

README 文档

README

Elgg 4.0

Utilities for AJAX requests

  • Deferred view rendering

Usage

Deferred view rendering

To defer view rendering, simply add 'deferred' => true to view vars.

echo elgg_view('my_view', [
	// tells the view system to defer view render
	'deferred' => true,
	
	// if set to false, placeholder will not be rendered
	// if set to a value, that value will be used as the placeholder
	// if not set, default ajax loader will be used
	'placeholder' => false,
	
	// you can pass other view vars, as you would with normal views
	// various Elgg data will be serialized and available to the deferred view
	// some of the values may need to be wrapped into a Serializable instance
	'entity' => get_entity(123),
	'user' => get_user(234),
]);

Ajax Forms

ajax/Form AMD module can be used to chain promise-based submit callbacks and submit the form via Ajax.

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);
});

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2021-10-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固