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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:43:44+00:00 2026-06-15T19:43:44+00:00

My Backbone app includes Views which depend on multiple models. For example, I define

  • 0

My Backbone app includes Views which depend on multiple models. For example, I define 2 models:

var user = new UserModel({id:1});
user.fetch();
var place = new PlaceModel({id:1});
place.fetch();

Now I want to render a View that depends on both these models:

var home = new House({owner: user, address: place});
home.render()

I don’t want to render the View until I’m sure all the models have loaded.
What is the right way to make sure that user and place have both been fetched before I render home?

I’m currently using a sequential process:

user.bind("change", function() {place.fetch();});
place.bind("change", function() {home.render();});
user.fetch();

But this gets unwieldy as the dependencies grow and I feel like there must be a better way…

  • 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-15T19:43:46+00:00Added an answer on June 15, 2026 at 7:43 pm

    Backbone fetch uses jQuery for AJAX calls, and like a plain $.ajax call, returns a jQuery Deferred object.

    This means that waiting for multiple calls to finish can be done quite elegantly using $.when:

    var place = new PlaceModel({id:96});
    var user = new UserModel({id:2458});
    var home = new House({owner: user, address: place});
    
    //both .fetch() calls return a promise
    //when waits for promises to be fulfilled (or rejected)
    $.when(place.fetch(), user.fetch())
      .done(home.render);
      .fail(showError);
    

    Edit: Earlier version of this answer claimed that Backbone.localStorage does not return a deferred, but it does, so this solution also works with that plugin.

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

Sidebar

Related Questions

I have a pretty basic Backbone app which uses a router to instantiate views
A Backbone app which I'm developing has a collection and a model, and associated
One feature of my Backbone app involves associating models of type A with models
We have a backbone.js app that displays a number of forms to the user.
I've got a Backbone.js/Rails app and I'm trying to create a new object through
I am using backbone.js to create a single page app. I am new to
In this hello world example of a Backbone app http://arturadib.com/hello-backbonejs/docs/5.html , the author renders
I'm building a backbone app using backbone-relational models (but that shouldn't matter for this
I'm writing a backbone app, and using the built-in event handling, which uses jquery
I've been following the cloudedit tutorial http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/ for adding backbone to my rails app,

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.