I'm not a Firebug expert, but this seems to work:
$.fn.log = function (brk){
console.log(this);
if (brk) debugger;
return this;
};
So now $(...).log() puts the jquery object on the console
and .log(true) also drops into the debugger (equivalent to setting a
breakpoint). I'm not
:[EMAIL PROTECTED] On
Behalf Of Benjamin Sterling
Sent: Thursday, December 27, 2007 7:09 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Chaining methods and Debugging?
Mike,
Is there a particular problem that you are trying to debug? In the
beginning, I would put console.log
Splitting up the lines helps visually, and Firebug will step to each
line. However, even without splitting them up, you can step-in, step-
out, step-in, step-out on any chained line, and Firebug will happily
step into and out of each method.
That said, jQuery makes it quite possible to
Is there a particular problem that you are trying to debug?
No, it just seems the pattern I find for practically every debug session I
encounter, both for Javascript/jQuery and for Drupal/PHP development.
In the beginning, I would put console.log in the callbacks (if the method
had one)
For quickie debugging to FIrebug, you could define
$.fn.log = function { console.log(this); return this;};
and now you've got a chainable log that you can put anywhere in the
chain:
$('p').log().css('color', 'red').log().slideDown()
etc.
I haven't tested this (I'm sitting in front of IE 7) but
Jeffrey Kretz wrote:
Another option would be to use the step into and step out
debug commands. Step into (F11) the css command, and
if you don't want to follow it all the way down, step out of
it, then step in (F11 again) to the slideDown command.
I hadn't considered that because I have
Danny wrote:
For quickie debugging to FIrebug, you could define
$.fn.log = function { console.log(this); return this;};
and now you've got a chainable log that you can put anywhere in the
chain:
$('p').log().css('color', 'red').log().slideDown() etc.
I haven't tested this (I'm sitting
Mike wrote:
That said, jQuery makes it quite possible to reduce an entire
application to a single line of code. Please resist this temptation,
or if you cannot, split up the statements as Benjamin has shown :)
Yeah, I've often thought writing an app as a single line of code was a
rather
Mike,
Is there a particular problem that you are trying to debug? In the
beginning, I would put console.log in the callbacks (if the method had one)
and that allowed me to see when one thing was be executed. Another tip that
should probably help, instead of doing.
9 matches
Mail list logo