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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:02:20+00:00 2026-06-04T14:02:20+00:00

I’m going through the process of learning Backbone.js and I’ve come across a few

  • 0

I’m going through the process of learning Backbone.js and I’ve come across a few things that look like they work… but behind the scenes, they might be causing some problems. One such issue is design patterns for swapping views.

I have a menu on the left (and corresponding view) that contains a list of users. Each user, when clicked, will display their corresponding list of movies to the right into another view. I do this by getting the model of the clicked user, building a new Movie collection based on that model, and rendering a new Movie View (to the right). If I click on another user, it does the same thing: it gets the user model, builds a new Movie collection, and renders a new Movie View to the right, replacing the DOM element. This looks fine — but I’m worried about all of the new objects/bindings that are being created, and potential issues that could arise. So, what are my alternatives?

(1) Should I be trying to have the view redraw when the collection changes? How do I do this if I’m creating new collections?

(2) Or should I be unbinding everything when another user is clicked?

Here is my userlist view:

Window.UsersList = Backbone.View.extend({
    el: $("#users"),

    initialize: function(){
        this.collection.bind('reset', this.render, this);
    },
    render: function(){
        var users = []; 
        this.collection.each(function(user){
            users.push(new UsersListItem({model: user}).render().el);
        },this);

        $(this.el).html(users);

        return this; 
    }
});

In my UsersListItem view I capture the click event and call show_user_movies in my controller:

show_user_movies: function(usermodel){
// fetchMovies() lazy-loads and returns a new collections of movies
        var movie_collection = usermodel.fetchMovies();
        movie_list = new MovieList({collection: movie_collection, model: usermodel});
        movie_list.render(); 
    },

Thanks for any suggestions.

  • 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-04T14:02:21+00:00Added an answer on June 4, 2026 at 2:02 pm

    Just re-use the same MovieList view along with it’s associated collection, using reset(models) to update the models in the collection, which should re-render the view. You can use the same pattern you have above with your MovieList view binding to the collection’s reset event and re-rendering itself at that time. Note that usermodel.fetchMovies() doesn’t follow the backbone asynchronous pattern of taking success/error callbacks, so I don’t think the code works as is (maybe you simplified for the purpose of this question), but the point is when the new set of models arrives from the server, pass it to movie_list.collection.reset and you’re good to go. This way you don’t have to worry about unbinding events and creating new views.

    show_user_movies: function(usermodel){
        // fetchMovies() lazy-loads and returns a new collections of movies
        movie_list.collection.reset(usermodel.fetchMovies().models); 
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

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.