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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:07:48+00:00 2026-05-26T06:07:48+00:00

General question if I am calling a webservice to return data related to one

  • 0

General question if I am calling a webservice to return data related to one of my Backbone models. Would it be better to call the webservice from within the model itself or should I pass in the results of the WS to the model on initialization.

I’m leaning towards incorporating the WS call within my model but then obviously may run into latency issues.

So where is the best place to handle this data retrieval?

  • 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-05-26T06:07:49+00:00Added an answer on May 26, 2026 at 6:07 am

    If the page that is rendering your HTML already knows the data that will go into your model, I definitely prefer rendering the data right into the model constructor. Something like this (assuming a Rails view, but that is just for the purpose of illustration):

    Let’s assume your controller has rendered some JSON data as @modelData.

    var modelData = <%= @modelData %>;
    var model = new TheModel(modelData);
    

    Doing it this way allows you to have your data immediately and not require a second call back to the service. I have used this approach several times with a lot of success.

    Edit

    To expand on this, this results in fewer calls to the server because the back end is rendering the data in the HTML or JS that gets returned to the client. The result (after view rendering) of the above code might be something like this:

    var modelData = {id: 5, first: "Collin", last: "Estes" }; // populated in first server call
    var model = new TheModel();
    

    If you to it the other way, however, you make two calls to the server:

    var model = new TheModel({id: 5});
    model.fetch();  // results in second server call
    

    The first call to the server is the one returning your code. The second happens when you call fetch.

    If you are asking something else, then I apologize. You might clarify what you mean by “where is the best place to handle these calls”.

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

Sidebar

Related Questions

just a general question are there any issues with using named pipes from a
general question is i like to build logger class that writes to single log
This is just a general question - I was sitting and waiting for a
Just a general question about what the best practice is: public void Foo() {
Ok this is a general question about how to solve this issue, not to
This is a general question about MVC as a pattern, but in this case
This is more a general question but my particular case involves a ruby/rails app
Yesterday I asked this general question about decimals and their internal precisions. Here is
I have a general question that is rather open-ended (i.e. depends on platform, application
This is a very general question: I was wondering whether it is possible to

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.