Use browser globals. Will fail if they are not yet loaded.
Save a copy of the original functions.
Override Marionette.Controller.constructor
. Here, we'll save
the region
passed in via options
and save a reference to this
controller.
The app controller has already been loaded.
Define this.region
so this controller knows where to show
itself.
Save the instance id. This will help with memory leak tracking.
Save instance in the registry.
Call the original constructor.
Default options
to {}
Set default options
When this controller is closed or destroyed, clean up the registry.
Remove instance from the registry.
Taken verbatim from backbone rails loading views:
the first view we show is always going to become the mainView of our controller (whether its a layout or another view type). So if this is a layout, when we show other regions inside of that layout, we check for the existance of a mainView first, so our controller is only closed down when the original mainView is closed.
Listen to close
and destroy
events on the view
.
Depending on which version of backbone we're using, a
different functions are called.
Show loading view
Allow develoompent debuggging since this is a development function.
Name constructor.
...after the entities are fetched, execute this callback ================================================================ // If the region we are trying to insert is not the loadingView then we know the user has navigated to a different page while the loading view was still open. In that case, we know to manually close the original view so its controller is also closed. We also prevent showing the real view (which would snap the user back to the old view unexpectedly) ================================================================ //
AMD. Register as an anonymous module.