承接 hgh/yii-js-event-handler 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hgh/yii-js-event-handler

Composer 安装命令:

composer require hgh/yii-js-event-handler

包简介

Using this library, You can define custom events and trigger them on other events trigger.

README 文档

README

Using this Library you can trigger your custom events on some another elements trigger.
MIT License Code Size

Instalation

 composer require hgh/yii-js-event-handler

Usage

Register Yii2 Asset

YiiJsEventHandlerAsset::register($this);  

Instantiate jQuery Plugin

There are two way of instantiate this jQuery plugin.

Use default attributes

To use default options you have to add two predefined attribute to your html element. You put your custom JS events into data-events-to-run. Separate your custom events using space. Then using data-on specify when these custom events should be trigger. The values that you can put in data-on follows jQuery events. Visit Form events, Mouse events and keyboard events .

<div data-on="click" data-events-to-run="customEvent anotherCustomEvent">  

Define your custom attributes

In other hand, You can define your custom attributes. For this you have to instantiate eventHandler plugin.

$(document).ready(function () {
    $("[data-my-custom-on-attribute]").eventHandler({
        onEventAttribute: "data-my-custom-on-attribute",
        toRunEventsAttribute: "data-my-custom-to-run-events-attribute"
    });
});

Now, you can use these attributes like this:

<div data-my-custom-on-attribute="click" data-my-custom-to-run-events-attribute="customEvent anotherCustomEvent">  

Sample

html
<div data-on="click" data-events-to-run="customEvent anotherCustomEvent">  
 Click Me to Run Custom Event</div>  
jquery
$(document).ready(function () {  
  $(document).on("customEvent", function () {  
  alert("Custom event triggered");  
 });  
  $(document).on("anotherCustomEvent", function () {  
  alert("Another custom event triggered");  
 });});  

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固