jQuery Logging

Written by on October 19th, 2007 in Ajax News.

Dominic Mitchell has created a mini jQuery logging plugin that ties Firebug to the call chain.

This means that if you are debugging something you can quickly add a .log(”….”) in the chain:

JAVASCRIPT:

  1.  
  2.   jQuery.fn.log = function (msg) {
  3.       console.log(”%s: %o”, msg, this);
  4.       return this;
  5.   };
  6.  

Now, I can just stuff a call to .log() in the middle of what I’m doing to see what I’m currently addressing. e.g.

JAVASCRIPT:

  1.  
  2. $(root).find(’li.source> input:checkbox’).log(”sources to uncheck”).removeAttr(”checked”);
  3.  

The nice thing about logging to firebug is that each node becomes clickable in the console, so you can immediately see the context.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/172132532/jquery-logging

Leave a Reply

You must be logged in to post a comment.



Site Navigation