Andrej12345
Andrej12345

Reputation: 117

How can I find from where is coming some event?

I have the following code

 $('body').unbind('completeSelectPdfFile');
            $('body').bind('completeSelectPdfFile', function (evnt, pdfURL, pdfFileName) {

the proflem here is that I can't find the source - so from where is happening this completeSelectPdfFile event. I searched through whole project and I can't any other place where this event is emitted. There is one place where we listen on this event.

The project is so big and I don't know if this is coming from some third party dependencies.How can i find this ?

Actually this event is triggered once I upload pdf file but I need to find the emitter

Upvotes: 0

Views: 32

Answers (1)

Alexandru Severin
Alexandru Severin

Reputation: 6218

via Debugging

Put a breakpoint in the source code, and then check the stack trace using the Browser Developer Tools while testing a pdf upload.

via logging

Write the stack trace inside the function of the event. Example:

$('body').bind('completeSelectPdfFile', function (evnt, pdfURL, pdfFileName) {
    console.log(Error().stack);
}

The console should indicate the stack trace while testing the pdf upload.

Follow the stack trace and you will find the source code which is emitting the event

Upvotes: 1

Related Questions