7 Replies - 651 Views - Last Post: 11 September 2012 - 05:27 PM

#1 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

Javascript Event-Handler Debugging Help

Posted 05 September 2012 - 05:04 PM

So I've recently started a new job doing some front-end JS work.


I can't show you the code for obvious reasons and I'm not even going to bother obfuscating it because its a huge amount of code (by my standards at least - several K lines spread over a couple of files).

I'll cut straight to the point, there is a popup box that can be accessed by two separate buttons.


If you could help me with debugging techniques at least, that would be great. Specifically:

1. Is there a way to break into the click event handler for a button element?

2. Is there a way to figure out what JS function created a specific DOM element? (I'm not sure when or what created the popup box in the first place)


ps, am I supposed to call it an event handler or a callback? or something else entirely?

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript Event-Handler Debugging Help

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: Javascript Event-Handler Debugging Help

Posted 05 September 2012 - 10:14 PM

1. modern JS debuggers let you set breakpoints anywhere (if that’s what you mean).
Was This Post Helpful? 0
  • +
  • -

#3 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

Re: Javascript Event-Handler Debugging Help

Posted 06 September 2012 - 12:11 AM

yes....thats the thing, i have no idea when the click event handler was added or even what function was attached.

if I could just click the button and automatically break into the next line of JS code to run, that's all I'm looking for. preferably, it would be smart enough to NOT break into any jquery.js code.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: Javascript Event-Handler Debugging Help

Posted 06 September 2012 - 12:47 AM

where the handler is added you have to find manually. good debuggers show you at least the functions that are registered to the event.
Was This Post Helpful? 0
  • +
  • -

#5 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

Re: Javascript Event-Handler Debugging Help

Posted 06 September 2012 - 01:34 AM

i really hate javascript. :(

thanks for the help anyways ;)
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: Javascript Event-Handler Debugging Help

Posted 06 September 2012 - 01:37 AM

compared to Java or C++ it is totally different. Many people hate it because of that ...
Was This Post Helpful? 0
  • +
  • -

#7 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

Re: Javascript Event-Handler Debugging Help

Posted 06 September 2012 - 01:57 AM

i think its even worse when you're a c# guy (that would be me). I've been very spoiled by the VS debuggers
Was This Post Helpful? 0
  • +
  • -

#8 DanSpline  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-September 12

Re: Javascript Event-Handler Debugging Help

Posted 11 September 2012 - 05:27 PM

With my SplinTech Javascript Debugger I can debug this scenario completely without knowing which function will be called and in which file.
Especially for that I added a feature to Pause in 5 seconds, that lets me skip all mouse over events and get in position before I click the button that will call that code.
Check it out: www.javascript-debugger.com

Daniel
www.remotedebugger.com
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1