classNameBindings: Dynamic CSS classes made easy

written by Dave Porter

As a mature framework, SproutCore is full of little features to make common tasks drop-dead simple – including some hidden gems. I recently added some documentation to the framework (and to the indispensable for one of them, and wanted to highlight it here on the blog too.

Dynamically adding and removing CSS classes on a view is a common need — for example, to swap background images when a property changes. But there’s no obvious way to do this; I burned my share of time trying to crack it manually, and I’ve watched other devs do the same. The usual solution ends up being a custom renderer, but that’s messy and verbose, operates at the wrong level of abstraction, and opens the door to all kinds of bugs if you’re not intimately familiar with the render API.

Enter classNameBindings. It’s is a quirky but powerful little property that makes dynamic class names a breeze. (No relation to the convenience key format fooBinding, by the way.) Here’s what classNameBindings looks like:

Continue reading

SproutCore User Groups and Docs Hackathon!

written by SproutCore

Things are taking off for folks interested in starting local user groups! 2009 saw the resurgence of the San Francisco group, and thus far, just in January, groups have been announced in both New York and Chicago, with dates on the way. If you’re interested in starting a group in your area, we’d love to help you get off your feet! Send us an email and we’ll get in touch 🙂

The next edition of the San Francisco User Group will be all about the docs—we’ll be gathering, hackathon style, to work on general documentation and the new SproutCore Guides. There’s been a major recent interest in getting our documentation resources up to snuff to keep up with the growing number of new developers looking to dive in, and this is the perfect way to keep the momentum going.

There’ll be a small, but not too small group gathering on-site in San Francisco, and a number of folks joining us via the web. We’ll start with some intros, talk about how to divvy up the work, and then pair off. SproutCore Core Team members Yehuda Katz and Peter Wagenet will be on-site and online leading the festivities and answering questions.

If you’d like to join us, on or off site, be sure to RSVP. To attend in person (there *will* be pizza and drinks, courtesy of the folks at Strobe), hit the main Meetup page. To join us remotely (and there are, alas, only a small number of spots, to be sure we can work with everyone in attendance), there’s a separate Meetup invite for you.