winternet-studio/yii2-libs 问题修复 & 功能扩展

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

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

winternet-studio/yii2-libs

最新稳定版本:v1.18.7

Composer 安装命令:

composer require winternet-studio/yii2-libs

包简介

Misc helpful libraries for Yii2. Eg. a helper for simplified handling of common tasks with AJAX, modals, and display of messages from Javascript code

README 文档

README

Different Yii2 libraries for helping you to write less code and organize it better.

JsHelper is for simplified handling of common tasks with AJAX, modals, and display of messages from Javascript code. See the source code for understanding the purpose of this library.

Please note that this library is primarily for my own use and might be lacking proper documentation and overall explanation of things, even though I try to document everything in the way I code and write comments. Also be aware that features might change without proper notice even though I try to always make code backwards compatible.

Installation

The preferred way to install this extension is through composer.

First install Yii2, then:

composer require winternet-studio/yii2-libs

Usage

Once the extension is installed, simply use it in your code by :

<?php
use winternet\yii2\JsHelper;

echo JsHelper::initAjax();  //call within <body>
echo JsHelper::standardModal(['id' => 'StandardModal2']);
?>

Javascript code:

// To make an AJAX call:

appJS.ajax({
	url: '/your/url',
	type: 'POST',
	dataType: 'json',
	data: {var1: 'something', var2: 'something else'}
});

// To show a standard modal (either initAjax() or initModal() must have been called beforehand):

appJS.showModal('Here goes the <b>content</b> for your modal.');

// To show a modal, specifying more options:

appJS.showModal({
	title: 'Modal title goes here',
	html: 'Here goes the <b>content</b> for your modal.',
	customModalSelector: '#StandardModal2',
	openCallback: function(modalRef) {
		// code for before modal is being opened
		// NOTE: not reexecuted when a closed modal is shown again (set up standard Bootstrap modal events for that)
	},
	openedCallback: function(modalRef) {
		// code for after modal has been opened
		// NOTE: not reexecuted when a closed modal is shown again (set up standard Bootstrap modal events for that)
	},
	closeCallback: function(modalRef) {
		// code for before modal is being closed
		// NOTE: not reexecuted when a closed modal is shown again (set up standard Bootstrap modal events for that)
	},
	closedCallback: function(modalRef) {
		// code for after modal has been closed
		// NOTE: not reexecuted when a closed modal is shown again (set up standard Bootstrap modal events for that)
	}
});

See the source code to understand how and why to use these libraries.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2017-06-11