GithubHelp home page GithubHelp logo

Comments (2)

mxriverlynn avatar mxriverlynn commented on May 3, 2024

the quick hack to work around this would be to attach your existing view to an existing element, and then to attach your view instance to the region manager manually. internally, the region manager stores the current view in this.currentView https://github.com/derickbailey/backbone.marionette/blob/master/backbone.marionette.js#L45

so you could do this:

var myView = new MyView({
  el: "#existing-element"
});

MyApp.myRegion.currentView = myView;

This would get the view attached to the region manager, so that the next call to MyApp.myRegion.show(...) would close it properly, and all that. It would also avoid the whole-sale replacement of the existing content.

A better solution, which I plan to put in place, would be to have an attachView method on the region manager object. This method would attach an existing view to the region manager in the same way that I just suggested, but it would encapsulate that logic and anything else that needs to happen.

It might also be a good idea to allow a view to be passed in to a region constructor through the options:

var myView = new MyView();

new Backbone.Marionette.RegionManager({
  initialView: myView
});

and have this set up so that it will just attach the existing view without rendering and replacing what's currently there.

from backbone.marionette.

mxriverlynn avatar mxriverlynn commented on May 3, 2024

this is done in the dev branch. you can either initialize with currentView: myView or call attachView(myView)

from backbone.marionette.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.