Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:13:04+00:00 2026-06-15T12:13:04+00:00

I am using a Router for my navigation and layout management (is that right!?)

  • 0

I am using a Router for my navigation and layout management (is that right!?) and seem to have a hit a problem:

backboneQuote.Routers.ApplicationRouter = Backbone.Router.extend({

routes: {
    "" : "home",
    "edit/:id": "quoteEdit"
},

initialize: function(){
    this.headerView = new backboneQuote.Views.headerView();
    $('.header').html(this.headerView.render().el);

    if(!this.itemsView){
        this.items = new backboneQuote.Collections.ApplicationCollection([
            {id: 1, name: "item 1"},
            {id: 2, name: "item 2"},
            {id: 3, name: "item 3"}
        ]);

        this.itemsView = new backboneQuote.Views.itemsView({collection: this.items});
    }
    this.content = $('.container');
},

home: function(){

    this.content.html(this.itemsView.render());

},

quoteEdit: function(id){
    this.editQuoteView = new backboneQuote.Views.editQuoteView({model: this.items.where({id: parseInt(id, 10)})});
    $('#editQuote').html(this.editQuoteView.render().el);
    this.content.html($('#editQuote').html());
}

});

My itemsView render stuff:

renderItem: function(model){
    var itemView = new backboneQuote.Views.itemView({model: model});
    itemView.render();
    $(this.el).append(itemView.el);
    return this;
},

render: function(){
    this.collection.each(this.renderItem);
},

I click an element which navigates the app back to the “home” function (the click event is firing fine), but the content of “this.itemsView” never seem to get put back into “this.content” div. Can anyone spot anything wrong here?

As another massive help, if anyone could provide any overall BackboneJS wisdom on anything they see here then that would be a massive help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:13:05+00:00Added an answer on June 15, 2026 at 12:13 pm

    Typically, in Backbone apps, we write the render method to set the content of the views el. It is the responsibility of the code that calls render to ensure that the el is shown at the right place.

    In the router,

    home: function(){
    
        this.content.html(this.itemsView.render());
    
    }, 
    

    you are not accessing the .el property. First fix is to add that there.

    home: function(){
    
        this.itemsView.render();
        this.content.html(this.itemsView.el);
    
    }, 
    

    This assumes that your collection view has an el property, which Backbone views by default tend to have.

    Considering this is such a common task, the convention is to return this at the end of each views render method.

    render: function(){
        this.collection.each(this.renderItem);
        return this;
     },
    
    home: function(){
        this.content.html(this.itemsView.render().el);
    }, 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Restlet I have created a router for my Java application. From using curl,
Is anyone using Zend Navigation in conjunction with URLs that require dynamic parameters? Zend_Navigation
Using backbone.js and it's navigation/routes, and loading html template pages in from external files
I have an application that I am using a global route to query for
I have a Backbone.Marionette app configured using the AppRouter as well as the EventAggregator
Is it possible to connect two PCs without a router using just an ethernet
I am using language prefix in my app: Router::connect('/:language/:controller/:action/*', array(), array('language' => '[a-z]{3}')); When
I am using django multiple DB router concepts, having multiple sites with different db's.
I would like to get data using SNMP from a router. The data shall
I'm building a CMS using WebForms on .NET 4.0 and have the following route

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.