marionettejs/backbone.marionette — pull request #254 by osama-ibrahim (2012-09-22 18:29:57+00:00)
Title: Fixed an issue in `Layout.render` with `bindTo` function

### Why?

When binding an event to the `render` function in the `initialize` function, it holds a reference to it for the callback, then when `Layout.render` get called later, it actually replaces itself with a new function, and when the event get fired, it triggers the old `render`, and doesn't reInitialize the regions correctly.

Here is a couple of examples that shows the issue:
* [When binding the render function to a button](http://jsfiddle.net/osama/XSghY/1/)
* [When binding the render function to a model's event](http://jsfiddle.net/osama/XSghY/4/)

### What ?

Just provide an `if` condition to re-initialize the regions correctly if it's not the first render call, instead of replacing itself with another function.

### Discussion ?

First, Thanks for sharing such a great library that extends backbone.js with very useful components.

I've added two separate commits, the first one is the failing spec that show the issue, and the second one is the simple solution to fix it.