Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Klaus Hartl
Daemach wrote:
 Another fantastic tip.  Thank you.

Do not thank me :-) Thanks to Joe Hewitt for the incredible Firebug! I 
think it is the best tool ever for Frontend developing.


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Klaus Hartl
Ⓙⓐⓚⓔ wrote:
 Mike, I don't like breaking the chains... I just insert a debug in the
 middle of the chain...
 
 I use this for my debug:
 jQuery.fn.debug = function(message) {
   return this.log('debug:' + (message || '')
 +[).each(function(){jQuery.log(this);}).log(]);
 }
 jQuery.fn.log = jQuery.log = function(message) {
   if (!message) message = 'UNDEFINED'
   if (typeof message  == object) message = jsO(message)
   if(window.console  window.console.log) //safari
   window.console.log(message)
   else if(window.console  window.console.debug) //firebug
   window.console.debug(message)
   else
   jQuery(body).prepend(message+ br/)
   return this
 }

Thanks Jake, very nice! While reading your first sentence I thought 
What about a logger in the chain and there you go ;-)

Straight into my toolbox... :-)

-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Klaus Hartl
Ⓙⓐⓚⓔ wrote:
 Mike, I don't like breaking the chains... I just insert a debug in the
 middle of the chain...
 
 I use this for my debug:
 jQuery.fn.debug = function(message) {
   return this.log('debug:' + (message || '')
 +[).each(function(){jQuery.log(this);}).log(]);
 }
 jQuery.fn.log = jQuery.log = function(message) {
   if (!message) message = 'UNDEFINED'
   if (typeof message  == object) message = jsO(message)
   if(window.console  window.console.log) //safari
   window.console.log(message)
   else if(window.console  window.console.debug) //firebug
   window.console.debug(message)
   else
   jQuery(body).prepend(message+ br/)
   return this
 }

One question though: What is jsO() ?


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Klaus Hartl
Jörn Zaefferer wrote:
 Daemach schrieb:
 Is there a list of rules somewhere that define where this is that or the
 reverse?
   
 I posted something recently that roughly covers this: 
 http://bassistance.de/2007/01/23/unobtrusive-clear-searchfield-on-focus/
 
 Maybe that helps.
 

Nice, looks exactly like the one I posted last week... ;-)

http://jquery.com/discuss/2007-January/022164/


-- Klaus


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Jörn Zaefferer
Klaus Hartl schrieb:
 Jörn Zaefferer wrote:
   
 Daemach schrieb:
 
 Is there a list of rules somewhere that define where this is that or the
 reverse?
   
   
 I posted something recently that roughly covers this: 
 http://bassistance.de/2007/01/23/unobtrusive-clear-searchfield-on-focus/

 Maybe that helps.

 

 Nice, looks exactly like the one I posted last week... ;-)

 http://jquery.com/discuss/2007-January/022164/
   
Haha. That may explain where I got the idea from. No worries, eh?

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Fil
  http://bassistance.de/2007/01/23/unobtrusive-clear-searchfield-on-focus/
  http://jquery.com/discuss/2007-January/022164/

Why not use .one()?

$('#searchbox')
.one('focus',
function() {
$(this).attr('value','');
}
)

This is what I did for http://www.monde-diplomatique.fr/

This way you can search for search :)

-- Fil


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Ⓙⓐⓚⓔ
YES we all need tiny mundane utilitarian  plugins! Not to be
confused with glorious or exotic or wild!
They  cut development time down!

On 1/24/07, Klaus Hartl [EMAIL PROTECTED] wrote:
 Jörn Zaefferer wrote:
  Nice, looks exactly like the one I posted last week... ;-)
 
  http://jquery.com/discuss/2007-January/022164/
 
  Haha. That may explain where I got the idea from. No worries, eh?

 No, no... :-)

 I wonder if we should add a folder like Micro plugins to SVN where
 these little helpers could go into... Brandon posted some as well recently.


 -- Klaus


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Brice Burgess
Klaus Hartl wrote:
 Ⓙⓐⓚⓔ wrote:
   
 Mike, I don't like breaking the chains... I just insert a debug in the
 middle of the chain...

 I use this for my debug:
 jQuery.fn.debug = function(message) {
  return this.log('debug:' + (message || '')
 +[).each(function(){jQuery.log(this);}).log(]);
 }
 jQuery.fn.log = jQuery.log = function(message) {
  if (!message) message = 'UNDEFINED'
  if (typeof message  == object) message = jsO(message)
  if(window.console  window.console.log) //safari
  window.console.log(message)
  else if(window.console  window.console.debug) //firebug
  window.console.debug(message)
  else
  jQuery(body).prepend(message+ br/)
  return this
 }
 

 Thanks Jake, very nice! While reading your first sentence I thought 
 What about a logger in the chain and there you go ;-)

 Straight into my toolbox... :-)

 -- Klaus
I smell plugin ;)

~ Brice


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-24 Thread Ⓙⓐⓚⓔ
what looks like a plug-in and smells like a plug-in should be a plug-in!

http://jpassoc.com/js/jquery-debug.js

the updated (and corrected) debug that I use for Firefox+Firebug and
Safari... it works with IE ... but it's not pretty!

Any more info on debugging in IE can be incorporated, and a simpler
jso would be fine additions!


On 1/24/07, Brice Burgess [EMAIL PROTECTED] wrote:
 I smell plugin ;)

 ~ Brice


-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
this is not this! this is that!

this is very much dependent on where this is used. inside an .each(),
this is an element.
inside a plugin this is a jquery object ( an array of elements).

the this you used is weird on one, it is probably a null jquery object
with no elements... but I've never poked in to look!

as far as debugging... everyone with firefox debugs with firebug...
some use others... and Internet Explorer users often flip over to
firefox for better debugging!

   $('#test :textarea').before('Current length:nbsp;span id='+ this.id
+'_len'+this.value.length+'/spannbsp;characters').keypress( function()
{
   $('#'+this.id + '_len').css('color', ((this.value.length 
parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
   } );

might be better as
$('#test').bind('keypress',function(e){
 // do your dirty work with this, the textarea
   $(this).prev('span.count').html(this.value.length)
//  ...

}).before('spanCurrent length/spanspan
class=count0/spanspan chars/'


All with no extra IDs!

On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 I'm trying to sort out a problem with a selector and I'm not having much
 luck.  I'm using firebug at the moment, but I'm not able to easily see what
 the selector is picking up, if anything.  The first selector is here:

 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters')

 form action=boo name=test id=test
 textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form

 BTW the documentation doesn't show a :textarea selector in the form section
 - should that be added or is that where I'm going wrong?  I've tried using
 $(#Desc_512) as well and I'm still getting a this.value has no
 properties error.  I'm not sure it's grabbing the right element :/

 It would be insanely useful to write a doc talking about tools and code
 snippets you could use to troubleshoot jquery stuff.  Debugging hooks, like
 being able to pause and dump data (array contents, current dom element, etc)
 between chained functions would be great too. I'm a visual guy so being able
 to use something like dump()
 http://www.netgrow.com.au/files/javascript_dump.cfm
 http://www.netgrow.com.au/files/javascript_dump.cfm or sDumper() to see an
 object visually is hugely beneficial

 Is there a way to just return the jquery object (so I could see it in
 firebug's watch section) then pass it to another jquery function then join
 them all up when I know everything works?


 Here is the full function:
 ===
  $(document).ready(function(){

 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters').keypress( function()
 {
 $('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
 } );

  });

 form action=boo name=test id=test
 textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form

 ===
 --
 View this message in context: 
 http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8528477
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

This or that...This or that...  
http://bboyflexi.imeem.com/music/j-_J-4tV/the_choice_is_yours/ The choice is
yours! 

Is there a list of rules somewhere that define where this is that or the
reverse?  Or a very detailed description of what you're left with after a
selector is run and the object is passed to the next link in the chain? 
It's apparently arcane knowledge :)  I see that in the keypress you have
function (e) - where does e come from and how does it get passed?

Much thanks for taking the time - great example and I *think* I get it.  The
only things I'm not understanding are why you used #test as the first
selector, since that is the form ID, and why the before statement was added
last - or does that matter?

And why would you use a class as an identifier?  it might be best to change
the class to turn the text red/green rather than changing style elements. 
You might want to make the text bold too, for example.  I'm not opposed to
it, just trying to understand the thought process.  Would changing the class
break that selector?


Ⓙⓐⓚⓔ wrote:
 
 this is not this! this is that!
 
 this is very much dependent on where this is used. inside an .each(),
 this is an element.
 inside a plugin this is a jquery object ( an array of elements).
 
 the this you used is weird on one, it is probably a null jquery object
 with no elements... but I've never poked in to look!
 
 as far as debugging... everyone with firefox debugs with firebug...
 some use others... and Internet Explorer users often flip over to
 firefox for better debugging!
 
$('#test :textarea').before('Current length:nbsp;span id='+
 this.id
 +'_len'+this.value.length+'/spannbsp;characters').keypress(
 function()
 {
$('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
} );
 
 might be better as
 $('#test').bind('keypress',function(e){
  // do your dirty work with this, the textarea
$(this).prev('span.count').html(this.value.length)
 //  ...
 
 }).before('spanCurrent length/spanspan
 class=count0/spanspan chars/'
 
 
 All with no extra IDs!
 
 On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 I'm trying to sort out a problem with a selector and I'm not having much
 luck.  I'm using firebug at the moment, but I'm not able to easily see
 what
 the selector is picking up, if anything.  The first selector is here:

 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters')

 form action=boo name=test id=test
 textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form

 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 
 -- 
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8549419
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

Hmm - and how could you make this code block set the initial length for
pre-populated fields - that was the reason I was trying to use that first
this.  Or was it that?

Maybe I just need to run a second selector that sets all the spans?


Ⓙⓐⓚⓔ wrote:
 
 this is not this! this is that!
 
 this is very much dependent on where this is used. inside an .each(),
 this is an element.
 inside a plugin this is a jquery object ( an array of elements).
 
 the this you used is weird on one, it is probably a null jquery object
 with no elements... but I've never poked in to look!
 
 as far as debugging... everyone with firefox debugs with firebug...
 some use others... and Internet Explorer users often flip over to
 firefox for better debugging!
 
$('#test :textarea').before('Current length:nbsp;span id='+
 this.id
 +'_len'+this.value.length+'/spannbsp;characters').keypress(
 function()
 {
$('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
} );
 
 might be better as
 $('#test').bind('keypress',function(e){
  // do your dirty work with this, the textarea
$(this).prev('span.count').html(this.value.length)
 //  ...
 
 }).before('spanCurrent length/spanspan
 class=count0/spanspan chars/'
 
 
 All with no extra IDs!
 
 On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 I'm trying to sort out a problem with a selector and I'm not having much
 luck.  I'm using firebug at the moment, but I'm not able to easily see
 what
 the selector is picking up, if anything.  The first selector is here:

 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters')

 form action=boo name=test id=test
 textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form

 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 
 -- 
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8549615
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Nate Cavanaugh

*EDIT*
I have a feeling you're either coming from Prototype, or straight from DOM
scripting. I had the same preconceived notions when I first started with
jQuery...

So here is my attempt to do what you're trying to do (and from my testing,
it all works :))

$('#test textarea').each(function(){
//this refers to the current element
$(this).before('Current length:
span'+this.value.length+'/spannbsp;characters')
}) // Does NOT return the newly created item, but is still on the textarea
.keyup(function(){
//this refers to the current element
var max_length = this.id.split('_')[1];
var length_color = this.value.length  max_length ? 'red' : 'green';
var current_length = this.value.length || 0;
$(this).prev().html(current_length).css({color:length_color});
});


Daemach wrote:
 
 I'm trying to sort out a problem with a selector and I'm not having much
 luck.  I'm using firebug at the moment, but I'm not able to easily see
 what the selector is picking up, if anything.  The first selector is here:
 
 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters')
 
 form action=boo name=test id=test
   textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form
 
 BTW the documentation doesn't show a :textarea selector in the form
 section - should that be added or is that where I'm going wrong?  I've
 tried using $(#Desc_512) as well and I'm still getting a this.value has
 no properties error.  I'm not sure it's grabbing the right element :/
 
 It would be insanely useful to write a doc talking about tools and code
 snippets you could use to troubleshoot jquery stuff.  Debugging hooks,
 like being able to pause and dump data (array contents, current dom
 element, etc) between chained functions would be great too. I'm a visual
 guy so being able to use something like dump() 
 http://www.netgrow.com.au/files/javascript_dump.cfm
 http://www.netgrow.com.au/files/javascript_dump.cfm or sDumper() to see an
 object visually is hugely beneficial
 
 Is there a way to just return the jquery object (so I could see it in
 firebug's watch section) then pass it to another jquery function then join
 them all up when I know everything works?
 
 
 Here is the full function:
 ===
  $(document).ready(function(){
   
   $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters').keypress(
 function() { 
   $('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
   } );
 
  });
 
 form action=boo name=test id=test
   textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form
 
 ===
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8550126
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

Excellent.  And you're right.  Straight from DOM :)  Thanks very much for
taking the time.  I see where I was going wrong.


Nate Cavanaugh wrote:
 
 *EDIT*
 I have a feeling you're either coming from Prototype, or straight from DOM
 scripting. I had the same preconceived notions when I first started with
 jQuery...
 
 So here is my attempt to do what you're trying to do (and from my testing,
 it all works :))
 
 $('#test textarea').each(function(){
 //this refers to the current element
 $(this).before('Current length:
 span'+this.value.length+'/spannbsp;characters')
 }) // Does NOT return the newly created item, but is still on the textarea
 .keyup(function(){
 //this refers to the current element
 var max_length = this.id.split('_')[1];
 var length_color = this.value.length  max_length ? 'red' : 'green';
 var current_length = this.value.length || 0;
 $(this).prev().html(current_length).css({color:length_color});
 });
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8550204
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Michael Geary
 Is there a way to just return the jquery object (so I could 
 see it in firebug's watch section) then pass it to another 
 jquery function then join them all up when I know
 everything works?
 
  $('#test :textarea').before('Current length:nbsp;span id='+
this.id +'_len'+this.value.length+'/spannbsp;characters').keypress(
function()
 { 
  $('#'+this.id + '_len').css('color', ((this.value.length 
parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
  });

Yes, breaking up your chains is one of the first things do do when you're
having trouble. For example:

var $test = $('#test :textarea');
$test.before('Current length:nbsp;span id='+ this.id
+'_len'+this.value.length+'/spannbsp;characters');
$test.keypress( function() { 
 var $len = $('#'+this.id + '_len');
 $len.css('color', ((this.value.length 
parseInt(this.id.split()[1]))?'red':'green'));
 $len.html(this.value.length);
 });

Now you'll find it easier to debug.

-Mike


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

*cheer*  Exactly what I was asking for.  Thank you very much. 



Michael Geary wrote:
 
 Is there a way to just return the jquery object (so I could 
 see it in firebug's watch section) then pass it to another 
 jquery function then join them all up when I know
 everything works?
 
  $('#test :textarea').before('Current length:nbsp;span id='+
 this.id +'_len'+this.value.length+'/spannbsp;characters').keypress(
 function()
 { 
  $('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
  });
 
 Yes, breaking up your chains is one of the first things do do when you're
 having trouble. For example:
 
 var $test = $('#test :textarea');
 $test.before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters');
 $test.keypress( function() { 
  var $len = $('#'+this.id + '_len');
  $len.css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green'));
  $len.html(this.value.length);
  });
 
 Now you'll find it easier to debug.
 
 -Mike
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8550597
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Klaus Hartl
Daemach wrote:
 I'm trying to sort out a problem with a selector and I'm not having much
 luck.  I'm using firebug at the moment, but I'm not able to easily see what
 the selector is picking up, if anything.  The first selector is here:
 
 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters')
 
 form action=boo name=test id=test
   textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form
 
 BTW the documentation doesn't show a :textarea selector in the form section
 - should that be added or is that where I'm going wrong?  I've tried using
 $(#Desc_512) as well and I'm still getting a this.value has no
 properties error.  I'm not sure it's grabbing the right element :/
 
 It would be insanely useful to write a doc talking about tools and code
 snippets you could use to troubleshoot jquery stuff.  Debugging hooks, like
 being able to pause and dump data (array contents, current dom element, etc)
 between chained functions would be great too. I'm a visual guy so being able
 to use something like dump() 

If you already use FireBug, nothing easier than that...:

console.log( $('#test :textarea') );

I often do that first if something is wrong and I'm not sure if my 
selector is correct. The complete object (in this case the jQuery 
object) is logged to the console and you can than click on it to further 
inspect the object.

This also works pretty well with DOM objects:

console.log( $('#test')[0] );

A click on that logged element takes you directly to the DOM inspector 
to where the particular element is located in the tree. Saves you 
searching from body down and let's you easily check if newly elements 
are added in the correct plaze.

-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
inside every object's function there is a this... it all depends on
which object has the function!

inside an each function this is each element from the query
inside a plug-in this is the jquery object that has an array of elements.

most jq selectors keep a chain going so you have just what you started
with... some change the change so you have more or less elements, but
the chain continues, and you still have a jq object.

Why a class instead of an ID... I used the class like I would use a
local variable... since I can use prev() to find prior siblings and I
just want this one special one, I can code prev('span.special) to get
to the freshly added item.

SURE you can do the colors with a class too! you can change the class
or use the additive ability of classes to keep each part of the class
separate!


oops... I meant the id of the textarea.. not the form.

On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 This or that...This or that...
 http://bboyflexi.imeem.com/music/j-_J-4tV/the_choice_is_yours/ The choice is
 yours!

 Is there a list of rules somewhere that define where this is that or the
 reverse?  Or a very detailed description of what you're left with after a
 selector is run and the object is passed to the next link in the chain?
 It's apparently arcane knowledge :)  I see that in the keypress you have
 function (e) - where does e come from and how does it get passed?

 Much thanks for taking the time - great example and I *think* I get it.  The
 only things I'm not understanding are why you used #test as the first
 selector, since that is the form ID, and why the before statement was added
 last - or does that matter?

 And why would you use a class as an identifier?  it might be best to change
 the class to turn the text red/green rather than changing style elements.
 You might want to make the text bold too, for example.  I'm not opposed to
 it, just trying to understand the thought process.  Would changing the class
 break that selector?


 Ⓙⓐⓚⓔ wrote:
 
  this is not this! this is that!
 
  this is very much dependent on where this is used. inside an .each(),
  this is an element.
  inside a plugin this is a jquery object ( an array of elements).
 
  the this you used is weird on one, it is probably a null jquery object
  with no elements... but I've never poked in to look!
 
  as far as debugging... everyone with firefox debugs with firebug...
  some use others... and Internet Explorer users often flip over to
  firefox for better debugging!
 
 $('#test :textarea').before('Current length:nbsp;span id='+
  this.id
  +'_len'+this.value.length+'/spannbsp;characters').keypress(
  function()
  {
 $('#'+this.id + '_len').css('color', ((this.value.length 
  parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
 } );
 
  might be better as
  $('#test').bind('keypress',function(e){
   // do your dirty work with this, the textarea
 $(this).prev('span.count').html(this.value.length)
  //  ...
 
  }).before('spanCurrent length/spanspan
  class=count0/spanspan chars/'
 
 
  All with no extra IDs!
 
  On 1/23/07, Daemach [EMAIL PROTECTED] wrote:
 
  I'm trying to sort out a problem with a selector and I'm not having much
  luck.  I'm using firebug at the moment, but I'm not able to easily see
  what
  the selector is picking up, if anything.  The first selector is here:
 
  $('#test :textarea').before('Current length:nbsp;span id='+ this.id
  +'_len'+this.value.length+'/spannbsp;characters')
 
  form action=boo name=test id=test
  textarea cols=54 rows=5 id=Desc_512
  name=DescriptionSPORK/textarea
  /form
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context: 
 http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8549419
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
Mike, I don't like breaking the chains... I just insert a debug in the
middle of the chain...

I use this for my debug:
jQuery.fn.debug = function(message) {
return this.log('debug:' + (message || '')
+[).each(function(){jQuery.log(this);}).log(]);
}
jQuery.fn.log = jQuery.log = function(message) {
if (!message) message = 'UNDEFINED'
if (typeof message  == object) message = jsO(message)
if(window.console  window.console.log) //safari
window.console.log(message)
else if(window.console  window.console.debug) //firebug
window.console.debug(message)
else
jQuery(body).prepend(message+ br/)
return this
}


On 1/23/07, Michael Geary [EMAIL PROTECTED] wrote:
  Is there a way to just return the jquery object (so I could
  see it in firebug's watch section) then pass it to another
  jquery function then join them all up when I know
  everything works?
 
   $('#test :textarea').before('Current length:nbsp;span id='+
 this.id +'_len'+this.value.length+'/spannbsp;characters').keypress(
 function()
  {
   $('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
   });

 Yes, breaking up your chains is one of the first things do do when you're
 having trouble. For example:

 var $test = $('#test :textarea');
 $test.before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters');
 $test.keypress( function() {
  var $len = $('#'+this.id + '_len');
  $len.css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green'));
  $len.html(this.value.length);
  });

 Now you'll find it easier to debug.

 -Mike


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Jörn Zaefferer
Daemach schrieb:
 Is there a list of rules somewhere that define where this is that or the
 reverse?
   
I posted something recently that roughly covers this: 
http://bassistance.de/2007/01/23/unobtrusive-clear-searchfield-on-focus/

Maybe that helps.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Jörn Zaefferer
Ⓙⓐⓚⓔ schrieb:
 Mike, I don't like breaking the chains... I just insert a debug in the
 middle of the chain...

 I use this for my debug:
I just took a look at Firebug lite, it is really worth it's bytes. At 
least in IE it works fine, and you can use format log statements like this:

console.log(selector: %s jQuery: %o, abc, $(abc));

In FF, you can still click the jQuery object to see details, something 
that isn't possible if you do a manual concatenation:

console.log(selector:  + abc +  jQuery:  + $(abc));

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
I couldn't debug without firebug! I assume every body has their
favorite tricks... perhaps this should be on a fresh thread!

On 1/23/07, Jörn Zaefferer [EMAIL PROTECTED] wrote:
 Ⓙⓐⓚⓔ schrieb:
  Mike, I don't like breaking the chains... I just insert a debug in the
  middle of the chain...
 
  I use this for my debug:
 I just took a look at Firebug lite, it is really worth it's bytes. At
 least in IE it works fine, and you can use format log statements like this:

 console.log(selector: %s jQuery: %o, abc, $(abc));

 In FF, you can still click the jQuery object to see details, something
 that isn't possible if you do a manual concatenation:

 console.log(selector:  + abc +  jQuery:  + $(abc));

 --
 Jörn Zaefferer

 http://bassistance.de


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

Another fantastic tip.  Thank you.



Klaus Hartl wrote:
 
 Daemach wrote:
 I'm trying to sort out a problem with a selector and I'm not having much
 luck.  I'm using firebug at the moment, but I'm not able to easily see
 what
 the selector is picking up, if anything.  The first selector is here:
 
 $('#test :textarea').before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters')
 
 form action=boo name=test id=test
  textarea cols=54 rows=5 id=Desc_512
 name=DescriptionSPORK/textarea
 /form
 
 BTW the documentation doesn't show a :textarea selector in the form
 section
 - should that be added or is that where I'm going wrong?  I've tried
 using
 $(#Desc_512) as well and I'm still getting a this.value has no
 properties error.  I'm not sure it's grabbing the right element :/
 
 It would be insanely useful to write a doc talking about tools and code
 snippets you could use to troubleshoot jquery stuff.  Debugging hooks,
 like
 being able to pause and dump data (array contents, current dom element,
 etc)
 between chained functions would be great too. I'm a visual guy so being
 able
 to use something like dump() 
 
 If you already use FireBug, nothing easier than that...:
 
 console.log( $('#test :textarea') );
 
 I often do that first if something is wrong and I'm not sure if my 
 selector is correct. The complete object (in this case the jQuery 
 object) is logged to the console and you can than click on it to further 
 inspect the object.
 
 This also works pretty well with DOM objects:
 
 console.log( $('#test')[0] );
 
 A click on that logged element takes you directly to the DOM inspector 
 to where the particular element is located in the tree. Saves you 
 searching from body down and let's you easily check if newly elements 
 are added in the correct plaze.
 
 -- Klaus
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552729
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

Gotcha :)  Thanks again for the help!



Ⓙⓐⓚⓔ wrote:
 
 inside every object's function there is a this... it all depends on
 which object has the function!
 
 inside an each function this is each element from the query
 inside a plug-in this is the jquery object that has an array of elements.
 
 most jq selectors keep a chain going so you have just what you started
 with... some change the change so you have more or less elements, but
 the chain continues, and you still have a jq object.
 
 Why a class instead of an ID... I used the class like I would use a
 local variable... since I can use prev() to find prior siblings and I
 just want this one special one, I can code prev('span.special) to get
 to the freshly added item.
 
 SURE you can do the colors with a class too! you can change the class
 or use the additive ability of classes to keep each part of the class
 separate!
 
 
 oops... I meant the id of the textarea.. not the form.
 
 On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 This or that...This or that...
 http://bboyflexi.imeem.com/music/j-_J-4tV/the_choice_is_yours/ The choice
 is
 yours!

 Is there a list of rules somewhere that define where this is that or the
 reverse?  Or a very detailed description of what you're left with after a
 selector is run and the object is passed to the next link in the chain?
 It's apparently arcane knowledge :)  I see that in the keypress you have
 function (e) - where does e come from and how does it get passed?

 Much thanks for taking the time - great example and I *think* I get it. 
 The
 only things I'm not understanding are why you used #test as the first
 selector, since that is the form ID, and why the before statement was
 added
 last - or does that matter?

 And why would you use a class as an identifier?  it might be best to
 change
 the class to turn the text red/green rather than changing style elements.
 You might want to make the text bold too, for example.  I'm not opposed
 to
 it, just trying to understand the thought process.  Would changing the
 class
 break that selector?


 Ⓙⓐⓚⓔ wrote:
 
  this is not this! this is that!
 
  this is very much dependent on where this is used. inside an .each(),
  this is an element.
  inside a plugin this is a jquery object ( an array of elements).
 
  the this you used is weird on one, it is probably a null jquery object
  with no elements... but I've never poked in to look!
 
  as far as debugging... everyone with firefox debugs with firebug...
  some use others... and Internet Explorer users often flip over to
  firefox for better debugging!
 
 $('#test :textarea').before('Current length:nbsp;span id='+
  this.id
  +'_len'+this.value.length+'/spannbsp;characters').keypress(
  function()
  {
 $('#'+this.id + '_len').css('color', ((this.value.length
 
  parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
 } );
 
  might be better as
  $('#test').bind('keypress',function(e){
   // do your dirty work with this, the textarea
 $(this).prev('span.count').html(this.value.length)
  //  ...
 
  }).before('spanCurrent length/spanspan
  class=count0/spanspan chars/'
 
 
  All with no extra IDs!
 
  On 1/23/07, Daemach [EMAIL PROTECTED] wrote:
 
  I'm trying to sort out a problem with a selector and I'm not having
 much
  luck.  I'm using firebug at the moment, but I'm not able to easily see
  what
  the selector is picking up, if anything.  The first selector is here:
 
  $('#test :textarea').before('Current length:nbsp;span id='+ this.id
  +'_len'+this.value.length+'/spannbsp;characters')
 
  form action=boo name=test id=test
  textarea cols=54 rows=5 id=Desc_512
  name=DescriptionSPORK/textarea
  /form
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context:
 http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8549419
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 
 -- 
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552783
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

Please don't forget that a noob started this thread ;)  How do I use that
code block?



Ⓙⓐⓚⓔ wrote:
 
 Mike, I don't like breaking the chains... I just insert a debug in the
 middle of the chain...
 
 I use this for my debug:
 jQuery.fn.debug = function(message) {
   return this.log('debug:' + (message || '')
 +[).each(function(){jQuery.log(this);}).log(]);
 }
 jQuery.fn.log = jQuery.log = function(message) {
   if (!message) message = 'UNDEFINED'
   if (typeof message  == object) message = jsO(message)
   if(window.console  window.console.log) //safari
   window.console.log(message)
   else if(window.console  window.console.debug) //firebug
   window.console.debug(message)
   else
   jQuery(body).prepend(message+ br/)
   return this
 }
 
 
 On 1/23/07, Michael Geary [EMAIL PROTECTED] wrote:
  Is there a way to just return the jquery object (so I could
  see it in firebug's watch section) then pass it to another
  jquery function then join them all up when I know
  everything works?
 
   $('#test :textarea').before('Current length:nbsp;span id='+
 this.id +'_len'+this.value.length+'/spannbsp;characters').keypress(
 function()
  {
   $('#'+this.id + '_len').css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
   });

 Yes, breaking up your chains is one of the first things do do when you're
 having trouble. For example:

 var $test = $('#test :textarea');
 $test.before('Current length:nbsp;span id='+ this.id
 +'_len'+this.value.length+'/spannbsp;characters');
 $test.keypress( function() {
  var $len = $('#'+this.id + '_len');
  $len.css('color', ((this.value.length 
 parseInt(this.id.split()[1]))?'red':'green'));
  $len.html(this.value.length);
  });

 Now you'll find it easier to debug.

 -Mike


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 
 -- 
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552883
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
you slap it up in any of your scripts... or a special one (just for debugging)

then you can insert .debug(any label) anywhere along the chain!

On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 Please don't forget that a noob started this thread ;)  How do I use that
 code block?



 Ⓙⓐⓚⓔ wrote:
 
  Mike, I don't like breaking the chains... I just insert a debug in the
  middle of the chain...
 
  I use this for my debug:
  jQuery.fn.debug = function(message) {
return this.log('debug:' + (message || '')
  +[).each(function(){jQuery.log(this);}).log(]);
  }
  jQuery.fn.log = jQuery.log = function(message) {
if (!message) message = 'UNDEFINED'
if (typeof message  == object) message = jsO(message)
if(window.console  window.console.log) //safari
window.console.log(message)
else if(window.console  window.console.debug) //firebug
window.console.debug(message)
else
jQuery(body).prepend(message+ br/)
return this
  }
 
 
  On 1/23/07, Michael Geary [EMAIL PROTECTED] wrote:
   Is there a way to just return the jquery object (so I could
   see it in firebug's watch section) then pass it to another
   jquery function then join them all up when I know
   everything works?
  
$('#test :textarea').before('Current length:nbsp;span id='+
  this.id +'_len'+this.value.length+'/spannbsp;characters').keypress(
  function()
   {
$('#'+this.id + '_len').css('color', ((this.value.length 
  parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
});
 
  Yes, breaking up your chains is one of the first things do do when you're
  having trouble. For example:
 
  var $test = $('#test :textarea');
  $test.before('Current length:nbsp;span id='+ this.id
  +'_len'+this.value.length+'/spannbsp;characters');
  $test.keypress( function() {
   var $len = $('#'+this.id + '_len');
   $len.css('color', ((this.value.length 
  parseInt(this.id.split()[1]))?'red':'green'));
   $len.html(this.value.length);
   });
 
  Now you'll find it easier to debug.
 
  -Mike
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context: 
 http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552883
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Daemach

Well it looks really cool, but I couldn't get it to work :/  In the immortal
words of Riddick:

Pretend you're talking to someone who was educated in the penal system... 
In fact, don't pretend.

Here's what I tried:  

$('[EMAIL PROTECTED]').debug(boo).each( function() {$(this).before('Current
length: span style=color:'+((this.value.length 
parseInt(this.id.split(_)[1]))?'red':'green') +' id='+ this.id
+'_len'+this.value.length.toString()+'/span charactersbr').keyup(
function() {$('#'+ this.id +
'_len').html(this.value.length.toString()).css('color', ((this.value.length
 parseInt(this.id.split(_)[1]))?'red':'green')); } ); } );

and the error I get is:  jsO is not defined



Ⓙⓐⓚⓔ wrote:
 
 you slap it up in any of your scripts... or a special one (just for
 debugging)
 
 then you can insert .debug(any label) anywhere along the chain!
 
 On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 Please don't forget that a noob started this thread ;)  How do I use that
 code block?



 Ⓙⓐⓚⓔ wrote:
 
  Mike, I don't like breaking the chains... I just insert a debug in the
  middle of the chain...
 
  I use this for my debug:
  jQuery.fn.debug = function(message) {
return this.log('debug:' + (message || '')
  +[).each(function(){jQuery.log(this);}).log(]);
  }
  jQuery.fn.log = jQuery.log = function(message) {
if (!message) message = 'UNDEFINED'
if (typeof message  == object) message = jsO(message)
if(window.console  window.console.log) //safari
window.console.log(message)
else if(window.console  window.console.debug) //firebug
window.console.debug(message)
else
jQuery(body).prepend(message+ br/)
return this
  }
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context:
 http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552883
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 
 -- 
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8553297
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
ooops!
you can see the whole bunch of my little javascript toys at
http://jpassoc.com/js/my.js

here's jso
function jsO(obj) { // convert to simple js object for quick and dirty
access almost anything // not a good function for dom stuff because of
duplicate chidlren tags
if (typeof obj == object) {
var res = {\n;
var v = Array(0);
var val=obj.nodeValue;
if (val){
res += ' + val + '\n;
} else if (obj.nodeType){ // a dom node!
res +=  
obj.nodeName.replace(/-/g,_dash_).replace(/#/g,_hash_) + :{;
if (obj.hasAttributes()) {
var attrs = obj.attributes;
for (var i = 0; i  attrs.length; i++){
var attr=attrs[i];
v[v.length] = _ + attr.name + :' + 
attr.value + '\n;
}
}
if (obj.hasChildNodes()) {
var children = obj.childNodes;
for (var i = 0; i  children.length; i++){
v[v.length] =  + i + : + 
jsO(children[i]) + \n;
}
}
} else {
for (var item in obj){
try {
v[v.length] =  + item + : + 
jsO(obj[item]) + \n;
} catch (e) {
v[v.length] =  + item + :'whoops'\n;
}
}
}
res += v.join(,) + '}\n';
return res;
} else {
//if (obj.length  20) obj = obj.substr(0,20) + …;
 return obj;
}
}


On 1/23/07, Daemach [EMAIL PROTECTED] wrote:

 Well it looks really cool, but I couldn't get it to work :/  In the immortal
 words of Riddick:

 Pretend you're talking to someone who was educated in the penal system...
 In fact, don't pretend.

 Here's what I tried:

 $('[EMAIL PROTECTED]').debug(boo).each( function() {$(this).before('Current
 length: span style=color:'+((this.value.length 
 parseInt(this.id.split(_)[1]))?'red':'green') +' id='+ this.id
 +'_len'+this.value.length.toString()+'/span charactersbr').keyup(
 function() {$('#'+ this.id +
 '_len').html(this.value.length.toString()).css('color', ((this.value.length
  parseInt(this.id.split(_)[1]))?'red':'green')); } ); } );

 and the error I get is:  jsO is not defined



 Ⓙⓐⓚⓔ wrote:
 
  you slap it up in any of your scripts... or a special one (just for
  debugging)
 
  then you can insert .debug(any label) anywhere along the chain!
 
  On 1/23/07, Daemach [EMAIL PROTECTED] wrote:
 
  Please don't forget that a noob started this thread ;)  How do I use that
  code block?
 
 
 
  Ⓙⓐⓚⓔ wrote:
  
   Mike, I don't like breaking the chains... I just insert a debug in the
   middle of the chain...
  
   I use this for my debug:
   jQuery.fn.debug = function(message) {
 return this.log('debug:' + (message || '')
   +[).each(function(){jQuery.log(this);}).log(]);
   }
   jQuery.fn.log = jQuery.log = function(message) {
 if (!message) message = 'UNDEFINED'
 if (typeof message  == object) message = jsO(message)
 if(window.console  window.console.log) //safari
 window.console.log(message)
 else if(window.console  window.console.debug) //firebug
 window.console.debug(message)
 else
 jQuery(body).prepend(message+ br/)
 return this
   }
 
  
   --
   Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
   ___
   jQuery mailing list
   discuss@jquery.com
   http://jquery.com/discuss/
  
  
 
  --
  View this message in context:
  http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552883
  Sent from the JQuery mailing list archive at Nabble.com.
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context: 
 http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8553297
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___

Re: [jQuery] What tools should I use to troubleshoot jquery problems? (John Resig, jquery team, other gurus please share your tricks...)

2007-01-23 Thread Ⓙⓐⓚⓔ
it's really old code but it still works and it fit inside debug very
well... so I keep it!

On 1/23/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:
 ooops!
 you can see the whole bunch of my little javascript toys at
 http://jpassoc.com/js/my.js

 here's jso
 function jsO(obj) { // convert to simple js object for quick and dirty
 access almost anything // not a good function for dom stuff because of
 duplicate chidlren tags
 if (typeof obj == object) {
 var res = {\n;
 var v = Array(0);
 var val=obj.nodeValue;
 if (val){
 res += ' + val + '\n;
 } else if (obj.nodeType){ // a dom node!
 res +=  
 obj.nodeName.replace(/-/g,_dash_).replace(/#/g,_hash_) + :{;
 if (obj.hasAttributes()) {
 var attrs = obj.attributes;
 for (var i = 0; i  attrs.length; i++){
 var attr=attrs[i];
 v[v.length] = _ + attr.name + :' 
 + attr.value + '\n;
 }
 }
 if (obj.hasChildNodes()) {
 var children = obj.childNodes;
 for (var i = 0; i  children.length; i++){
 v[v.length] =  + i + : + 
 jsO(children[i]) + \n;
 }
 }
 } else {
 for (var item in obj){
 try {
 v[v.length] =  + item + : + 
 jsO(obj[item]) + \n;
 } catch (e) {
 v[v.length] =  + item + 
 :'whoops'\n;
 }
 }
 }
 res += v.join(,) + '}\n';
 return res;
 } else {
 //if (obj.length  20) obj = obj.substr(0,20) + …;
  return obj;
 }
 }


 On 1/23/07, Daemach [EMAIL PROTECTED] wrote:
 
  Well it looks really cool, but I couldn't get it to work :/  In the immortal
  words of Riddick:
 
  Pretend you're talking to someone who was educated in the penal system...
  In fact, don't pretend.
 
  Here's what I tried:
 
  $('[EMAIL PROTECTED]').debug(boo).each( function() 
  {$(this).before('Current
  length: span style=color:'+((this.value.length 
  parseInt(this.id.split(_)[1]))?'red':'green') +' id='+ this.id
  +'_len'+this.value.length.toString()+'/span charactersbr').keyup(
  function() {$('#'+ this.id +
  '_len').html(this.value.length.toString()).css('color', ((this.value.length
   parseInt(this.id.split(_)[1]))?'red':'green')); } ); } );
 
  and the error I get is:  jsO is not defined
 
 
 
  Ⓙⓐⓚⓔ wrote:
  
   you slap it up in any of your scripts... or a special one (just for
   debugging)
  
   then you can insert .debug(any label) anywhere along the chain!
  
   On 1/23/07, Daemach [EMAIL PROTECTED] wrote:
  
   Please don't forget that a noob started this thread ;)  How do I use that
   code block?
  
  
  
   Ⓙⓐⓚⓔ wrote:
   
Mike, I don't like breaking the chains... I just insert a debug in the
middle of the chain...
   
I use this for my debug:
jQuery.fn.debug = function(message) {
  return this.log('debug:' + (message || '')
+[).each(function(){jQuery.log(this);}).log(]);
}
jQuery.fn.log = jQuery.log = function(message) {
  if (!message) message = 'UNDEFINED'
  if (typeof message  == object) message = jsO(message)
  if(window.console  window.console.log) //safari
  window.console.log(message)
  else if(window.console  window.console.debug) //firebug
  window.console.debug(message)
  else
  jQuery(body).prepend(message+ br/)
  return this
}
  
   
--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
   
   
  
   --
   View this message in context:
   http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8552883
   Sent from the JQuery mailing list archive at Nabble.com.
  
  
   ___
   jQuery mailing list
   discuss@jquery.com
   http://jquery.com/discuss/
  
  
  
   --
   Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
   ___
   jQuery mailing list
   discuss@jquery.com
   http://jquery.com/discuss/
  
  
 
  --
  View this message in context: