Skip to content
Browse files

Merge branch 'master' of github.com:thoughtbot/backbone-support

  • Loading branch information...
2 parents 11ece82 + 1429346 commit 10b7234270fe5dff9445b8c7f4a65eb4a73e14f9 Chad Pytel committed Jan 23, 2012
Showing with 13 additions and 7 deletions.
  1. +11 −7 README.md
  2. +2 −0 spec/javascripts/support/jasmine.yml
View
18 README.md
@@ -1,11 +1,16 @@
-Helper and utility classes that fill out Backbone for serious development.
+There's no built-in garbage collection for Backbone’s event bindings, and
+forgetting to unbind can cause bugs and memory leaks.
+
+Backbone Support currently provides two utility classes, SwappingRouter and CompositeView,
+that introduce a `leave()` function, which unbinds and cleans up the view.
+They should be used where views are instantiated (in Router instances and in composite views).
Inspired by our projects and the Backbone.js on Rails book:
http://workshops.thoughtbot.com/backbone-js-on-rails
The book contains complete instructions and in-depth coverage of the internals
-of CompositeView and Swappingrouter, and an example application that shows
-their usage
+of CompositeView and SwappingRouter, and an example application that shows
+their usage.
### SwappingRouter
@@ -25,7 +30,7 @@ view by rendering that view into its own `el`:
if (this.currentView && this.currentView.leave) {
this.currentView.leave();
}
-
+
this.currentView = newView;
$(this.el).empty().append(this.currentView.render().el);
}
@@ -74,7 +79,7 @@ maintain a back-reference at `this.parent`. This is used to reach up and call
You'll need these, but chances are you already have them in your app:
-* jQuery
+* jQuery or Zepto
* Underscore
* Backbone
@@ -131,7 +136,7 @@ First off:
In your `config/application.rb`:
``` ruby
-config.middleware.use Rack::Static,
+config.middleware.use Rack::Static,
:urls => ['/vendor/plugins/backbone-support/lib/assets/javascripts']
```
@@ -157,7 +162,6 @@ end
Your individual specs will then need the full root path in `require`. For
example:
-
``` js
requirePublic = function(path) {
require("/public/javascripts/" + path);
View
2 spec/javascripts/support/jasmine.yml
@@ -14,6 +14,8 @@ src_files:
- vendor/jquery.js
- vendor/underscore.js
- vendor/backbone.js
+ - lib/assets/javascripts/backbone-support.js
+ - lib/assets/javascripts/backbone-support/support.js
- lib/**/*.js
# spec_files

0 comments on commit 10b7234

Please sign in to comment.
Something went wrong with that request. Please try again.