How to find the source (anonymous function) jQuery event source?

Most jQuery codes use anonymous functions, for example:

jQuery('someelements').someEvent(function() {
    // code here
});

This works well but is not suitable for debugging. I tried to find the source of some anonymous functions using both Firefox Firebug and the Chrome inspector, with javascript pause function, but the actual code that it calls is in the jQuery jQ file and the step-by-step code never tells which line or even that. The js file added this event. How can I determine where the action is defined?

+2
source share
5 answers

Google Chrome/Firefox, , jQuery () : Visual Event.

: Firefox, , Javascript ?

+1
+1

, . (, ), Chrome DevTools.

0

, , - , , . , .

.

jQuery('someelements').someEvent(function someEventHandler() {
    // code here
});

, , jquery dev . ret = ... .apply()

var handler = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler );
console.log("FIRE EVENT ", event.type, "HANDLER: ", handler.name||'Anonymous Function'); 
0
jQuery('someelements').someEvent(function(e) {
    // code here
alert(e.target);
});
-1

Source: https://habr.com/ru/post/1524418/


All Articles