Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Specified the language on some example blocks in the README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mason-stewart committed Jun 23, 2013
1 parent 74fc614 commit 61bbd3a
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,38 @@ Now, a `SwappingRouter` can take advantage of the `leave()` function, and
clean up any existing views before swapping to a new one. It swaps into a new
view by rendering that view into its own `el`:

swap: function(newView) {
if (this.currentView && this.currentView.leave) {
this.currentView.leave();
}

this.currentView = newView;
$(this.el).empty().append(this.currentView.render().el);
}
``` js
swap: function(newView) {
if (this.currentView && this.currentView.leave) {
this.currentView.leave();
}

this.currentView = newView;
$(this.el).empty().append(this.currentView.render().el);
}
```

An example SwappingRouter would look as follows:

Trajectory.Routers.Stories = Support.SwappingRouter.extend({
initialize: function(options) {
this.el = $("div.primary_content");
},
routes: {
"stories": "index",
"stories/new": "newStory"
}
index: function() {
var view = new Trajectory.Views.StoriesIndex();
this.swap(view);
},
newStory: function() {
var view = new Trajectory.Views.StoryNew({ model: new Story() });
this.swap(view);
}
}
``` js
Trajectory.Routers.Stories = Support.SwappingRouter.extend({
initialize: function(options) {
this.el = $("div.primary_content");
},
routes: {
"stories": "index",
"stories/new": "newStory"
}
index: function() {
var view = new Trajectory.Views.StoriesIndex();
this.swap(view);
},
newStory: function() {
var view = new Trajectory.Views.StoryNew({ model: new Story() });
this.swap(view);
}
}
```
### CompositeView
Expand Down Expand Up @@ -119,7 +123,9 @@ advantage of the asset pipeline.
Add the gem to your Gemfile:
gem "backbone-support"
``` ruby
gem "backbone-support"
```
And then `bundle install`.
Expand Down Expand Up @@ -158,7 +164,6 @@ or:
### With Jammit
First off:

rails plugin install git@github.com:thoughtbot/backbone-support.git
In your `config/application.rb`:
Expand Down

0 comments on commit 61bbd3a

Please sign in to comment.