Event Handler

授权协议 未知
开发语言
所属分类 jQuery 插件、 其他jQuery插件
软件类型 开源软件
地区 不详
投 递 者 陈德泽
操作系统 未知
开源组织
适用人群 未知
 软件概览

Event Handler plugin was made to make handling your event handlers a little easier. It adds one new method called eventH to jQuery which can only be invoked using $.eventH(). It expects two arguments (action, options) which must follow the following guidelines:
action must be a string == "bind" OR "unbind" OR "rebind" OR "add" OR "remove"
options must be an object (hash) that may contain the following:

  useList: {
    key: "the value must be set, but is not used",
    anotherKey: null,
    keying: "Bla",
    hex: null
  }
  skipList: {
    key: "same rules as useList"
  }
  newHandler: {
    type: ["click", "mouseover", "mouseout"],
    name: "key",
    selector: "jQuery Selector",
    func: [
      function(){
        //Click
      },
      function(){
        //MouseOver
      },
      function(){
        //MouseOut
      }
    ]
  },
  handlers: [
    {type:["change", "click", "focus", "blur"], name: "key", selector: "p", func: [function(){
        //Change
      },
      function(){
        //Click
      },
      function(){
        //Focus
      },
      function(){
        //Blur
      }
    },
    {type:["change", "click", "focus", "blur"], name: "key", selector: "p", func: [function(){
        //Change
      },
      function(){
        //Click
      },
      function(){
        //Focus
      },
      function(){
        //Blur
      }
    },...
  ]

NOTE: handlers should be passed the first time the function is invoked and should not be passed again (if it is, it will be discarded). Use the newHandler option and the add action to add new handlers.

The idea is that you call the eventH() method inside the jQuery ready function with action == "bind" and options containing just the handlers array. The keys that you define can be used in the useList and skipList when calling "bind" OR "unbind" OR "rebind" OR "remove" ("add" doesn't use the useList or skipList).

The "rebind" action is useful when you have an element who's content keeps changing (completely) but keeps the same selectors there.
For Example:

<div class='cont'>
  <span class='name'>Name</span>
</div>

Now lets say you changed the content of the div with $(".cont").html("Name 2");. Any event handlers you had registered with the span would be lost. If you call the rebind action with the key you defined for that span, you can recover all event handlers. (NOTE: This is only common in ajax applications where the server is returning HTML).

The "unbind" action is useful if you want to temporarily remove all event handlers from an element (or set of elements). It is also internally used for the "rebind" action.

The "bind" action can be called if/when you want to recover the event handlers you unbound with the "unbind" action.

The "add" action is useful if you want to add an element to the list for lator use with "unbind"/"rebind"/"bind". Or if you want to add multiple event handlers to a single group of evelent(s) (eg. mouseover, mouseout, click...) all at once. The normal jQuery way of doing this would be like this: $("selector").mouseover(...).mouseout(...).click(...);

This plugin is no where near perfect and I'm hoping to have some time to improve it.

 相关资料
  • 问题内容: class SomeClass extends Component{ someEventHandler(event){ } render(){ return } } 我看到零件的不同版本。 版本有何不同?还是只是偏爱问题? 问题答案: 绑定不是特定于React的东西,而是在Javascript中的工作方式。每个函数/块都有其自己的上下文,对于函数而言,其功能更特定于其调用方式。当添加E

  • 我有两个Axon@EventHandler需要按一定的顺序处理(它们有不同的事件要处理)。我读到我需要: 使用org.axonframework.config.processingGroup注释所有涉及的事件处理程序(order似乎只适用于一个processingGroup);批注是在类级别完成的, 使用org.springframework.core.annotation.order确定优先级;

  • 我正在用JAXB解析XML,并创建了一个事件处理程序,如果验证出现问题,它将显示错误。 调用事件处理程序并输出错误;如果调用了事件处理程序(在打印输出之后),如何抛出异常 在代码中,我不知道何时调用事件处理程序,它只是在验证错误时调用;我需要在事件处理程序返回后将文件移动到 /dir的能力。 我的事件处理程序如下所示: 处理时,我的代码如下所示:

  • 我有两门课。在一节课上,我创建并发起了一个活动,如下所示: 客户添加类 MyWindow类 现在,当我从类调用方法时,(当我订阅方法到事件时),不会被调用。调试器显示为空。我搜索了几个小时,没有找到解决办法。我跟随了这个链接,但仍然为空。如有任何指导/帮助,将不胜感激。

  • 我是JavaFX新手,在使用setOnMouse点击方法时遇到了问题。在下面的代码中,我尝试在嵌套循环中添加一个事件处理程序,为创建的每个矩形分配一个事件处理程序,单击鼠标后,该事件处理程序将矩形变为灰色。它似乎根本不起作用,我不知道为什么。我是否遗漏了需要添加的内容? 编辑:这是FXML内容,根节点只是一个空白窗格 此外,自定义屏幕类定义了循环中使用的2d座位数组

  • 问题内容: 我试图严格遵守使用$ http或$ resource进行文件上传的angularjs代码。 这些事件根本没有触发。我想念什么? 参考资料 https://github.com/angular/angular.js/issues/14436 https://github.com/angular/angular.js/pull/11547 问题答案: 发布查询后找到它。感觉很蠢。我必须在b

  • 我有一个环形缓冲区和一个事件处理程序。这用作消息传递服务器的入站缓冲区。 在偶处理程序中,它执行一些AMQP服务调用,有时由于调用没有超时而等待(下划线协议库中调用AMQP服务的错误)。对于2000tps,这使我的4096大小的环形缓冲区在一瞬间就满了。因为由于上述事实,onEvent调用线程似乎没有从该方法返回,并且在onEvent()内无限等待。 目前,不可能为该调用创建超时。 问题是: 当d

  • 我是一个完全的初学者,在玩javafx。我的第一次尝试:[FXML] 和控制器类: 这将导致以下错误: 解析onAction=“#Handle”时出错,事件处理程序不在命名空间中,或者脚本中存在错误。 虽然我的控制器类被明确设置为父锚链烷的控制器。