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 s
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
rat
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
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 ha
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
>> 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)
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 reduce
ailto:[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 i
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.
$('p').css('color','red').slide
The thing about chaining is that you need to make sure any plugin/
function returns a jQuery object , so that any chained calls have
something to work with.
Your plugin doesn't actually return anything for the .click() function
to use.
As a quick (and dirty) modification - added a return:
e
> From: Jonathan Sharp <[EMAIL PROTECTED]>
> To: jquery-en@googlegroups.com
> Sent: Wednesday, May 2, 2007 11:51:25 AM
> Subject: [jQuery] Re: Chaining methods
>
> //plugin
>jQuery.fn.toggleText = function (evalText1, evalText2){
>$(this)
: jquery-en@googlegroups.com
Sent: Wednesday, May 2, 2007 11:51:25 AM
Subject: [jQuery] Re: Chaining methods
//plugin
jQuery.fn.toggleText = function (evalText1, evalText2){
$(this).html(($(this).text() ==
evalText1)?evalText2:evalText1);
}
jQuery.fn.toggleText = function
//plugin
jQuery.fn.toggleText = function (evalText1, evalText2){
$(this).html(($(this).text() ==
evalText1)?evalText2:evalText1);
}
jQuery.fn.toggleText = function(txt1, txt2) {
return this.each(function() {
$(this).html( $(this).text() == txt1 ?
13 matches
Mail list logo