online Thomas
online Thomas

Reputation: 9381

Is there an easy way to know what line of jQuery script called an event?

I'm working on a drupal module (irrelevant) and I'd like to recreate a javascript/jQuery event. If I use chrome and go to event listeners I see the jQuery script is called on line 57, however this doesn't really help as:

The reason is that I'd like to recreate this (ajax probably) call: enter image description here

So does anyone know of a trick like a chrome plugin or something? It could shave a lot of time for me.

Upvotes: 5

Views: 135

Answers (2)

Mohd Abdul Mujib
Mohd Abdul Mujib

Reputation: 13928

If you are setting a correct breakpoint then you should be getting a Call Stack on the Source Tab, on the right hand side. There you should be able to track down the file which initiated the call.

And as they say, a picture speaks a thousand words..

Jquery Trace the call to the file.

And to further elaborate on your question,

It is always advisable to use an uncompressed jQuery.js (Or for that matter any .js) during the development, as you might have already figured out.

Steps for someone new.

  1. Inside the compressed file just get the version no.
  2. Download the respective uncompressed version of the jquery from the official website.
  3. If you don't want to change the code just rename the uncompressed file to jQuery.min.js or whatever is currently being loaded, so It will work as a drop in replacement.

Upvotes: 6

Tariq
Tariq

Reputation: 2871

Try chrome devtools, for example:

Sources -> Event Listener Breakpoints (to the right) -> Mouse -> click

Upvotes: 0

Related Questions