Socket
Book a DemoInstallSign in
Socket

find-event-handlers

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-event-handlers

get list of event handlers on a given DOM object (grabbed via jQuery)

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
2
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

findHandlersJS

Installation:

npm i find-event-handlers --save

Stop wasting your time looking for where those handlers are registered, use findHandlersJS and discover them instantly.

Usage:

findEventHandlers(eventType, jQuerySelector)

Imagine you want to find all the "click" event handlers for all the buttons that are immediate children of the div with id="myDiv":

findEventHandlers("click", "div#myDiv > :button")

It will return an array with the element names, the jQuery $._data event information and the list of elements that that event handler covers (targets).

For example, if div#myDiv has a delegate handler with the selector :button and there is a button with id="save" inside the div, you would get this result:

[{
    element: div#myDiv,
    events: [{
        type: "click",
        handler: function() {...},
        namespace: "",
        selector: ":button",
        ...
        targets: [button#save]        
    }]
}]

If you are using the console on Chrome, you can right click the handler, click show function definition and add breakpoints to debug the handlers.

To detect whether or not there are any handlers attached to an element, use a library like lodash to determine whether or not the returned object is empty.

Keywords

handler

FAQs

Package last updated on 13 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts