model view controller - Debugging javascript after pulling the method in via AJAX -
i using mvc , jquery pull in function server (as partial view generate on fly , append body of html) , execute it. works fine, can view in fiddler, debugging terrible. pull in method using like:
$("#makegrid").click(function (e) { $.get('/gridder/basicgrid', callbackfn); function callbackfn(data) { //append markup dom $('body').append(data); // call js function partialview here generategrid(); } });
whether best practice or not i'm not sure, if 'view source' after ajax command, code isn't visible, , using debugger; command doesn't seem work. eg:
function generategrid() { alert("start"); debugger; alert("end"); }
creates 2 alerts doesn't bring debugger though firebug active. discussion raises similar issue. worked around using debugger twice (this bug meant gone now) or opening firebug in new window (no luck). eval('debugger;'); suggested in thread no good!
any suggestions? (including using tool other firebug if needed, want debug, not view fiddler-style)
doesn't conclusive answer coming on one. others' reference, ended getting debugging going in vs2010 itself, follows:
a) must use ie vs default browser. firefox doesn't playing. if you're using mvc, default browser selector doesn't come against views etc in webforms. quick solution create empty .html page in root , right click bastard 'browse with...' , select desired default browser. tada.
b) next, in ie's advanced options, make sure untick 'disable javascript debugging' options.
c) now, can use debugger; command in script within view break execution of dynamically generated script. go vs , highlight line. because it's generated says [dynamic script] @ top. breakpoints still don't seem work annoyingly.
d) in ie, js errors reported in console. give line number , column, highlighting file. if have sent dynamic partial view though, highlights these coordinates in original page file, not applicable. rather, go equivalent coordinates in "script block [dynamic]" tab of vs.
in truth more useful mvc development firebug have offered.
cheers
Comments
Post a Comment