Created
          February 11, 2014 09:35 
        
      - 
      
- 
        Save bazilio91/8931828 to your computer and use it in GitHub Desktop. 
    Caching Region for Marionette.js
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | define(['marionette', 'underscore'], function (Marionette, _) { | |
| /** | |
| * @class CachingRegion | |
| */ | |
| return Marionette.Region.extend({ | |
| show: function (view) { | |
| this.ensureEl(); | |
| this.currentView = view; | |
| if (!_.isUndefined(view.cached)) { | |
| this.open(view); | |
| Marionette.triggerMethod.call(this, 'show', view); | |
| Marionette.triggerMethod.call(view, 'show'); | |
| return; | |
| } | |
| view.cached = true; | |
| view.render(); | |
| this.open(view); | |
| Marionette.triggerMethod.call(this, 'show', view); | |
| Marionette.triggerMethod.call(view, 'show'); | |
| } | |
| }); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment