Permalink
Browse files

reusing layouts Closes #3

  • Loading branch information...
1 parent e1ecd5f commit 752d69ce7a39714c8495de61f7399158a8be8503 @tbranyen committed Nov 27, 2011
Showing with 3 additions and 9 deletions.
  1. +1 −1 README.md
  2. +2 −8 backbone.layoutmanager.js
View
@@ -108,7 +108,7 @@ var LoginView = Backbone.View.extend({
These example templates are defined using a common pattern which leverages
how browsers treat `<script></script>` tags with custom `type` attributes.
-This is how `LayoutManager` expects templates to be structured by default.
+This is how `LayoutManager` expects templates to be defined by default (using script tags).
#### Main layout ####
View
@@ -135,19 +135,13 @@ var LayoutManager = Backbone.LayoutManager = Backbone.View.extend({
context = options.serialize.call(manager);
}
- // If contents is a JST, call it
- if (_.isFunction(contents)) {
+ // Change the innerHTML only if `reuse` is falsy or its a new layout
+ if (!options.reuse || !manager.layout || manager.layout !== url) {
manager.el.innerHTML = options.render.call(options, contents, context);
-
- // Not currently this layout, so set it in the innerHTML
- } else if (!manager.layout || manager.layout !== url) {
- manager.el.innerHTML = contents;
}
// Iterate over each View and apply the render method
_.each(manager.views, function(view, name) {
- // TODO: Add reset logic here
-
// Render into a variable
view.render(viewRender).then(function(contents) {
// Apply partially

0 comments on commit 752d69c

Please sign in to comment.