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

  • Home
  • SEARCH
  • 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 8635723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:02:55+00:00 2026-06-12T10:02:55+00:00

I am trying to override backbone model fetch function using easyXDM, the reason for

  • 0

I am trying to override backbone model fetch function using easyXDM, the reason for using easyXDM is because the server is located on different domain.

here is the fetch code:

     fetch: function(options)
     {
        model = this;
        a = true;
        this.xhr.request({
           url: "http://server.dev:9000/users/" + this.id,
           method: "GET"
        }, function(response){
           console.log(response.data);

           var jsonResponse = JSON.parse(response.data);

           if (jsonResponse.status == 'success'){
             model.set({
                firstName : jsonResponse.data.first_name,
                lastName :   jsonResponse.data.last_name,
                email : jsonResponse.data.email,
                companyName : jsonResponse.data.company.name,
                companyId : jsonResponse.data.company.id
             }) 
           }
        });

     }

And here is code on the controller fetching the model

    var user = new UserModel({id : id});
    user.fetch();
    alert(user.get('firstName')); // display undefined

So the problem is whenever I call fetch, the model is still not populated yet.
I am thinking because the easyXDM request is async so its not yet populated.
Is there anyway to make sure that the model is populated and ready to use?
perhaps using a callback, any direction on how to create a callback?

  • 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-12T10:02:56+00:00Added an answer on June 12, 2026 at 10:02 am

    Sorry, I misunderstood your question initially. Fetch is async with or without easyXDM, so you have to either implement the onsuccess callback of fetch, or check if the model is set (using length or other method) before doing any operations on it. This post may help as well:

    Backbone.js: Elegant way to check if data ready and if the dataset is empty

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

Sidebar

Related Questions

I am trying to override one function by replacing it with a different version.
I'm trying to override the behavior of an external function in user32.dll because I
I'm trying to override the method 'send_confirmation_instructions' as shown here: http://trackingrails.com/posts/devise-send-confirmation-mail-manually-or-delay-them with: def send_confirmation_instructions
I am trying to override the load() (abstract) method in org.primefaces.model.LazyDataModel class (from Primefaces
I'm trying to override the setter setView in a UIViewController subclass, the reason being
Trying to create a backbone plugin that inherits from Backbone.Model but overrides the sync
I am trying to override the Page_PreInit function inside my class _Default which inherits
I am trying to override an existing method in ESAPI OWASP library, by using
I'm trying to override Backbone.sync in order to set the id attribute every time
I'm trying to override a built in parseFloat function in JavaScript . How would

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.