2

Here is my javascript file yogaspace.js

var input = document.getElementById('location');
var options = {
types: ['(cities)'],
componentRestrictions: { country: "us" }
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
debugger;
var result = autocomplete.getPlace();

this is the whole file and it is being called in the index.cshtml file at the bottom of the view like this.

@Scripts.Render("~/bundles/js")

and the js is a bundle that has the yogaspace.js file in it. The script gets used and the autocomplete feature works fine but the breakpoint at "debugger" never gets triggered. I also tried setting a breakpoint but that doesn't work as well. Any help! I read in other posts that VS has some problems with javascript debugging but it says that adding debugger; will always work.

VS 2013, MVC 5, Razar View Engine, IE 11

chuckd
  • 13,460
  • 29
  • 152
  • 331
  • 3
    If you put a breakpoint in you need to debug using IE. It won't trigger in Firefox or Chrome. You can use the browsers built in debugger but it wont pick up visual studio breakpoints. – heymega Jan 24 '15 at 21:52
  • I'm using IE11! I've tried putting in a breakpoint but it doesn't break nor does it stop at debugger. – chuckd Jan 24 '15 at 22:28
  • Have you got developer tools on and the debugger running? – heymega Jan 24 '15 at 22:31
  • how do you check to see if the developer tools are running? I'm pretty sure I have the debugger running. I'm pressing F5 to debug my app. I found this link but not sure if it applies to me. http://stackoverflow.com/questions/20807845/visual-studio-2013-cant-debug-javascript-in-cshtml – chuckd Jan 24 '15 at 22:45
  • In IE press F12 or go to Settings>Developer tools then debugging! – heymega Jan 24 '15 at 22:47
  • I tried this and there is a little box inside the debugger window that says "the script debugger failed to connect to the target process. A debugger is already attached." All I did was press F5 to start a debugging session then went to settings->debugger. – chuckd Jan 24 '15 at 22:54
  • Check this out - https://msdn.microsoft.com/en-us/library/z959x58c.aspx – heymega Jan 24 '15 at 22:58
  • I feel like your getting off topic to my original post. I want to debug in VS, not IE. If I put my javascript back into the view in a script tag I can hit the debugger; line and see what the values are, but it still won't hit any breakpoints I set. Why won't it hot any breakpoints and why doesn't it work when I have the javascript in it's own .js file? – chuckd Jan 24 '15 at 23:20
  • That link outlines how to set it up to work in VS. I originally thought it may not have been configured correctly. Have you tried disabling the bundling and minifying? – heymega Jan 24 '15 at 23:43

1 Answers1

0

I had to set this value to false in the BundleConfig.cs file.

BundleTable.EnableOptimizations = false;

Now debugging with breakpoints works!

chuckd
  • 13,460
  • 29
  • 152
  • 331