Skip to content


Subversion checkout URL

You can clone with
Download ZIP


calling insertView(s) from outside render doesn't work #97

nickryall opened this Issue · 6 comments

2 participants


When using insertView() or insertViews() from a custom function within my parent view, I am seeing the following issues:

  1. SubView will not render unless I manually call render() on them
  2. If I manually call render on the SubView the reference to the manger (e.g. 'layout' or 'manage' ) is not passed on so the custom layout manger render method throws an error.

Example code:

// Won't render
customFunction: function() {
  this.insertView(new App.Views.Image({
    model: model

// Will render but resulting view not handled by the manager
customFunction: function() {
  this.insertView(new App.Views.Image({
    model: model


App.Views.Image = new Backbone.View.extend({
    render: function(manage) {
      var view = manage(this)


Throws an error of 'manage is not a function'


Hey man, thanks for the issue. Can you check out:

This is a simplistic example of what you're trying to do, but can you figure out how to make it break like it is in your case?


Hey thanks for your reply and thanks for this project, it's been very useful for a project I'm working on. I've created the issue I'm seeing here:

You'll see that I'm trying to insert a view into another by calling insertView() from within a custom function of the parent view.


I'm not seeing any JavaScript in your fiddle, can you verify it works for you, and if not, update?


Sorry about that. How about this one:


Thats because you're missing the render call when inserting. There are many times you would want to insert several views in a loop and if layoutmanager rendered each one it would be very slow. Check out this:

I only chained a render call to the insertView and everything is fine. Please let me know if this fixes your issue so this can be closed.


Ah okay I see. I as doing this when trying to manually call render

this.insertView(new MySubView().render());

when I should have been doing this:

 this.insertView(new MySubView()).render()

Thanks for clearing this up for me and thanks again for your work on this.

@nickryall nickryall closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.