The JavaScript blog.


tips feedback

Tips and Links

Posted on .

I've got a bunch of JavaScript-related bookmarks to share. Things that
don't belong in a post by themselves, collected from reader comments and

Unit Testing

Jakub Suder wrote a detailed article on JavaScript unit
This was found in a comment on my JavaScript Unit

Learning Advanced JavaScript

The consensus seemed to be that David Flanagan's Definitive
is one of the best
books for studying JavaScript, according to comments on Learning

Firefox 3.6

Firefox 3.6 is out today. There's a
video overview here: What's New in Firefox
, and full release

  • Support for new DOM and HTML5 specifications including the Drag & Drop API and the File API
  • Support for new CSS attributes such as gradients, background sizing, and pointer events
  • Continued support for downloadable web fonts using the new WOFF font format
  • The ability for web developers to indicate that scripts should run asynchronously to speed up page load times


Everyone still seems fascinated with the JavaScript Flash renderer,
Gordon. The GitHub repo now has over 1000 followers -- it's one of the most popular JavaScript projects
on GitHub.

Atlas and Cappuccino

I wrote about Atlas in Atlas: Your First
. The beta programme is
still rolling on, and it looks like Cappuccino
is getting closer to version 0.8.


PostageApp is a bulk email service that targets web developers, and has a JSON-based API so it should be easy
for JavaScript developers to use. I saw this in a tweet from


We got some positive feedback on our "JavaScript Performance


jquery events tips ringo

jQuery Custom Events

Posted on .

jQuery makes it easy to bind and trigger custom events. Although it's
not immediately apparent from the
, creating custom
events is simple and very useful.

Binding Custom Events

Events can be bound to DOM nodes like this:

$("#myElementId").bind("myCustomEvent", function(event) {
  alert("myCustom event happened!");

Triggering Custom Events

jQuery's trigger function is
used to instigate the event, passing the name of the event as a string
like this:


If you want to pass data to the handler you can use an event

var myCustomEvent = jQuery.Event("myCustomEvent");
myCustomEvent.usefulInformation = "some data";
myCustomEvent.otherStuff = "some other data";


Another cool feature of jQuery events is
namespacing, which supports triggering or unbinding specific groups of handlers without having to
reference them directly.

You can add a namespace when binding an event which can be referenced
when you unbind or trigger it. It's possible to use multiple namespaces
at once.

$('.myCSSClass').bind('myEvent.myNamespace.myOtherNamespace', function(){alert('namespaced event')}); 

If you specify a namespace when unbinding or triggering events, you need
to match one of the bound namespaces (or alternatively, if no namespace
is specified it matches everything).

$('.myCSSClass').bind('myEvent.myNamespace', function(){alert('namespaced event')}); 
$('.myCSSClass').trigger('myEvent.myNamespace'); // mentioned explicitly: will trigger
$('.myCSSClass').trigger('myEvent');  // not specified: will trigger 
$('.myCSSClass').unbind('myEvent.differentNamespace'); // won't unbind