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 8172461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:47:30+00:00 2026-06-06T21:47:30+00:00

Just started with backbone.js and javascript. On my collection, I can listen for ‘reset’

  • 0

Just started with backbone.js and javascript.
On my collection, I can listen for ‘reset’ event and make it call the ‘render’ function of my view(this). But I add the view into the DOM in my router like this:

$('#container').html(view.render().el)

I call render().el (which i assume returns some HTML text) and add it to my container div. Calling render on my view alone is useless. So why does my view update perfectly on ‘reset’ event which merely calls the render function (which is useless as it just returns self(a view object), the actual updating occurs in my router where the view’s rendered el gets append into my container div)?

I am following a tutorial that why I know the answer, just don’t know the reason behind it.

Thanks

  • 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-06T21:47:31+00:00Added an answer on June 6, 2026 at 9:47 pm

    In $('#container').html(view.render().el) you insert the view‘s top-element to your #container -element, like so:

    <div id="container">
      <div class/id="whatever-your-view-has-defined">
        <!-- THIS IS WHERE YOUR VIEW PUTS ANYTHING GOING TO $(this.el) or this.$el -->
      </div>"
    </div>
    

    So when you call render before the view’s corresponding collection or model has finished it’s fetch, you’ll probably just insert the view’s own element into the container. Now when your collection/model has done fetching and triggers a reset, the view renders again. I suppose your render looks something like this:

    render: function() {
    
      // do something with $(this.el) or this.$el
    
      // loop through collection and insert something from each model to the view
      // OR
      // take the view's model and insert it to the view
      // I reckon the inserting is done with templates or jQuery manipulation
    
      //finally 
      return this; // return this to allow chaining render to other things like calling el
    }
    

    This basically means that your first render stages your view into the DOM and the one called after reset fills it out with content. You could forego the

    $('#container').html(view.render().el)
    

    part, if you for example set your view’s id-property to be content, the view will automatically seek out the element with the identifier content to be it’s element. But then all your view’s content will be inserted directly into the content-element.

    Hope this helped, comment if something is still unclear!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started testing FireMonkey and can't find a way to make dynamically sized/positioned components.
I've just started using Backbone.js. I want to create a Collection and add some
I just started with backbone.js and is currently making a page which has a
I just started with backbone.js, and one thing that I noticed is that sometimes
I just started to delve into backbone.js and I am not sure what is
Just started mongo and started having issue with querying already. i have a collection
I just started learning Backbone.js, and have been working on (what else) a simple
So I've just started to write tests for my in-progress javascript app, using sinon.js
Can someone help me understand how to make Ryan Bate's screencast on Backbone.js work
We've just started using Backbone and I'm trying to get a handle on a

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.