Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 script is minified and unreadable
  • I'd like to know what line of the jQuery using scripts called the event (what selector and what body of it's function), not the jQuery script itself
  • It's not easy to find the file by just searching for fit selectors as there are 100's of loaded javascripts files thanks to drupal and it's installed modules.

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.

like image 583
online Thomas Avatar asked Oct 14 '15 15:10

online Thomas


People also ask

Where is the jQuery code executed?

jQuery code runs on the web browser. In general, jQuery code is executed on the client side.

WHAT IS ON event in jQuery?

The on() method attaches one or more event handlers for the selected elements and child elements. As of jQuery version 1.7, the on() method is the new replacement for the bind(), live() and delegate() methods.

Why we use jQuery to wire up events?

jQuery makes it straightforward to set up event-driven responses on page elements. These events are often triggered by the end user's interaction with the page, such as when text is entered into a form element or the mouse pointer is moved.


1 Answers

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.
like image 154
Mohd Abdul Mujib Avatar answered Nov 14 '22 22:11

Mohd Abdul Mujib