Search code examples
javascriptbackbone.jsbackbone-viewsbackbone-boilerplatebackbone-layout-manager

Backbone LayoutManager Re-Render SubViews


I'm using BBB with the great LayoutManager for the views. Unfortunately, i can't find a way to re-render specific subviews. Here is my setting:

Home.Views.Layout = Backbone.Layout.extend({
    template: "home/home",
    el: "#main",
    views: {
        "#left-menu-container": new Home.Views.Leftmenu(),
        "#searchbox": new Home.Views.Searchbox(),
        "#content": new Home.Views.Content()
    }
});

Home.HomeView = new Home.Views.Layout();
Home.HomeView.render();

Home.Views.AddEditPatient = Backbone.View.extend({
    template: "......",
    events: {
        'click .dosomething': 'dosomething'
    },
    dosomething: function(){
        // [dosomething]

        // Only Render Sub-View, e.g. #content here...
   }
});

I don't want to re-render the whole layout, what would be possible by calling Home.HomeView.render() again, but how can i render only the sub-view in this setting?


Solution

  • I think you want to add to do something like this with backbone.layoutmanager

    thisLayout.setView("#content", new View()).render();

    The backbone.layoutmanager v0.6.6 documentation might be helpful http://documentup.com/tbranyen/backbone.layoutmanager/#usage/nested-views

    Also check http://vimeo.com/32765088