1

I've run through all the obvious answers for this type of question (symbols not being available) and come up empty, but I'm sure this is possible: shouldn't I be able to step through jquery scripts in Visual Studio in the debugger? I just can't get it to work. All of my breakpoints show up as shown in the attached screen snapshot. I can never hit a breakpoint.

I've made sure script debugging is enabled in Internet Explorer. Thinking it might be related to having the minified versions of jquery in use, I went with the full-blow versions. Still no joy. Relevant screen snapshots attached. I can't be the first person to have seen this, but I've googled the heck out of it, and no joy...

I see this at runtime for any and all jquery code... note the unavailable breakpoint:

enter image description here

Here's how I'm referencing jquery:

enter image description here

This is the only thing I could find in IE that might prevent me from debugging and as you can see, I'm good to go:

enter image description here

markaaronky
  • 1,231
  • 12
  • 29
  • Why do .NET developers not want to use the built in debuggers in the browser? Seems like a common question. Have you tried to debug with the browser's developer tools? – epascarello Oct 24 '16 at 21:21
  • http://stackoverflow.com/questions/15568245/how-to-debug-only-javascript-in-visual-studio – epascarello Oct 24 '16 at 21:24
  • 1
    With respect, I'm not sure why a developer would want to leave one environment that already has a wonderful debugging environment to use another debugger, especially since Visual Studio supports the debugging of multiple languages/scripts already without ever leaving the IDE. There are myriad examples of why I wouldn't want to do this; one is that I transfer values from jquery scripts to values in my MVC models and I'd like to see both in a watch window in my VS IDE. So my question remains: is it possible to debug jquery in Visual Studio? Thank you for the reply – markaaronky Oct 25 '16 at 13:28

1 Answers1

5

You could debug in the browser instead which is pretty powerful. Just write debugger; before $('#dialog').dialog('open'); and you will be fine. Remember to have the Developer Tools opened. Depending on the browser it's F12. I hope this help.

dotnetspark
  • 551
  • 4
  • 23
  • 1
    I appreciate the reply but this isn't really what I'm after. I have rather complex interactions between jquery code and an mvc app and having to stop and write "debugger" instead or being able to arbitrarily set a breakpoint, then having to debug outside of the VS IDE, kind of defeats the purpose of my intentions. It seems odd that I could not be able to simply step through jquery statements in Visual Studio... it's just javascript,right? – markaaronky Oct 25 '16 at 13:34
  • in that case, you may want to look at https://msdn.microsoft.com/en-us/library/afys1kyy(v=vs.80).aspx and https://msdn.microsoft.com/en-us/library/k2h50zzs(v=vs.80).aspx – dotnetspark Oct 25 '16 at 14:22
  • 1
    btw yopez, I've noticed that if you add "debugger" in the script, from then on you can debug inside of visual studio afterwards--no need to debug in the browser. Granted, it's inconvenient to have to go into the script and add a line that says "debugger" before I can begin to set breakpoints in visual studio, but it's at least a workaround and does indicate to me that Visual Studio understands jquery symbols,etc.needed for debugging (in other words, no need to using an external debugging tool). So thank you for the tip! – markaaronky Oct 25 '16 at 16:13
  • Good to know! I have never tried that. I guess your question is now answered, right? – dotnetspark Oct 25 '16 at 16:16
  • Not completely, TBH, but I think its a close enough work around that I can mark this thread and your response as the answer. If you aren't very careful where you put the debugger statement you end up breaking execution of your page unintentionally, and TBH it's still inconvenient to have to stop and type in a debug command in the right place just to make the breakpoints work, but, HEY, IT GETS THE JOB DONE :-) Thank you for the suggestion! – markaaronky Oct 25 '16 at 16:32
  • 1
    You're absolutely right :-) but so far, it's the only solution it comes to my mind. I watched this on Channel 9, John Galloway used it at some point, to debug something. Thanks – dotnetspark Oct 25 '16 at 16:46