background preloader

Backbone

Facebook Twitter

Extending Objects in Underscore. Underscore is a very nice library, it’s what Backbone JS is built on.

Extending Objects in Underscore

What I’ve come to like about it is its ability to provide very helpful functions that let you more effectively work with sets of data. Below is the code we’ve seen before, only slightly modified because we’re using Underscore’s extend function now. And the output: This is the exact same output as our Ext JS example. Since there’s nothing new, I can’t go on about too many differences, but I can, however, bring up another related function in Underscore, defaults.

The defaults method is interesting in that it works very similarly, but turns our familiar objects into something new that the others haven’t yet done. This one fills in missing properties and ignores any match applied after. The extend and defaults functions work almost opposite from each other, but are great to have side-by-side when you need them. For more information: extend and defaults. Oh hey, I'm a Senior Consultant for Headspring in Austin, TX. Backbone.EventBinder: Better Event Management For Your Backbone Apps. One of my most popular blog posts in recent history is my Zombies!

Backbone.EventBinder: Better Event Management For Your Backbone Apps

RUN! Post where I outline the possibility and problem of memory leaks and “zombie” views and other objects in Backbone applications. There’s a good chance, in fact, that if you’ve built a Backbone application, you’ve read this article already. It seems to get more traffic and more “THANK YOU!!!!” Responses than any other blog post (and rightfully so, IMO). Down in the comments of that post, Johnny Oshika posted a link to his solution for managing events. And now it’s even easier to use this in your app, even if you’re not using Marionette. Backbone.EventBinder I recently extracted Backbone.EventBinder from Marionette and turned it in to it’s own repository in the MarionetteJS Github org, so that anyone and everyone building Backbone applications can take advantage of this without having to re-write it in their app.

From the EventBinder wiki: When To Use Backbone.EventBinder Views And Memory Leaks Custom Event Groupings. Backbone.js. Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

Backbone.js

The project is hosted on GitHub, and the annotated source code is available, as well as an online test suite, an example application, a list of tutorials and a long list of real-world projects that use Backbone. Backbone is available for use under the MIT software license. You can report bugs and discuss features on the GitHub issues page, on Freenode IRC in the #documentcloud channel, post questions to the Google Group, add pages to the wiki or send tweets to @documentcloud. Backbone is an open-source component of DocumentCloud. Downloads & Dependencies (Right-click, and use "Save As") Backbone's only hard dependency is Underscore.js ( >= 1.5.0). Introduction Many of the examples that follow are runnable. Upgrading to 1.1.