Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Shorthand for searching a View's DOM in Backbone

Sometimes you use a pattern so frequently that you don’t realize that other people might not know about it. Here’s the most recent one for me — I was surprised that this wasn’t being used in the last few codebases I’ve seen:

If you’re using Backbone.js, instead of writing


or worse



$('span.timestamp', view.$el)

Backbone provides a $ method such that you can simply write


It’s less to type and it doesn’t hurt readability.

  1. Varand says:

    I was google-ing for this issue but couldn’t find correct answer anywhere.

    Your post helped me a lot.


  2. Bob says:

    Elegant solution. Thank you!

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *