0

I am looking the definition of javascript function addHorizonLoadEventin following code, This function is defined in the separate file javascript file, So How I will track js file where the definition of that javascript is defined.

addHorizonLoadEvent(function() {
      show_hide_datepickers();
});

Please see the image, I found the definition of addHorizonLoadEvent, But I want to go to the file, How I will go? enter image description here

geeks
  • 2,025
  • 6
  • 31
  • 49
  • I guess you have to open all those external javascript files and search for it. – JavaScript Jul 20 '15 at 10:22
  • 1
    Add add a breakpoint at the line with the function you want and press `F11`, or use `CTRL + SHIFT + F` (in chrome) to search in all files for it. Also take a look at [this](http://stackoverflow.com/questions/9828876/find-javascript-function-definition-in-chrome) – Bobby Tables Jul 20 '15 at 10:26
  • you could look at the library too.. https://github.com/openstack/horizon/blob/65db6d33aa40a202cd16ad60e08273f715a67745/horizon/templates/horizon/client_side/_script_loader.html – Pogrindis Jul 20 '15 at 10:30
  • @toby - This should be an answer. Ctrl-Shift-F would have saved me so much time in the past. Nice trick. :) – enhzflep Jul 20 '15 at 10:30
  • @enhzflep before i found out about the shortcut i used to switch to FF just to search in all files so i know the feeling – Bobby Tables Jul 20 '15 at 10:37
  • @toby - haha. I do the same thing with C/C++ code and Visual Studio - only opening it if I need to debug something that's proving bothersome. – enhzflep Jul 20 '15 at 10:47

1 Answers1

2
  1. CTRL + SHIFT + F search in all files (for chrome) or CTRL+ ALT + F(for FF)
  2. Add a breakpoint the line with the function and when that breakpoint is triggered (when that function is being executed) press F11 to step into it.
  3. If you're function is already in scope just console.log it (like foo not foo()) and click on the output)
Bobby Tables
  • 2,953
  • 7
  • 29
  • 53
  • I followed you instruction, Please see the updated question with image, As you told that after adding breakpoint you can press F11, But F11 is not working.... – geeks Jul 20 '15 at 10:47
  • @NeelabhSingh The debugger has to reach that line of code for F11 to work. So somehow you have to trigger the `addHorizonLoadEvent` from the UI. As for the search part just clicking on one of the results should be enough. – Bobby Tables Jul 20 '15 at 10:53