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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:11:46+00:00 2026-06-14T22:11:46+00:00

I am trying to learn Backbone.js and have stuck at an issue. model.save is

  • 0

I am trying to learn Backbone.js and have stuck at an issue. model.save is not updating my model value, though model.fetch updates the value fine.

Please see my code below and let me know if I am doing anything wrong here:

Model

var Person = Backbone.Model.extend({

    url: "CreatePerson",
    defaults: {
        name: "",
        age: 0
    },
initialize: function(){

this.on("change:name",function(){

        alert("Updated value is: "+this.get("name"));
    });
    }

});

I am creating an instance of this model on my html page, below is the code:

var person = new Person({name:"manish"});

person.save(person,{

        wait: true,
        success: function(){
            alert("Data saved: "+person.toJSON().name);
        },
        error: function(){
            alert("Sorry, something wrong went with the system");
        }       
    });
person.fetch({

        success: function(){
            alert("Data Fetched: "+person.get("name"));
        }
    });

On both save and fetch, I am returning the following JSON data from the server:

{"name":"Logan","age":23}

Interestingly, for save, the change event is not fired and the alert box gives me the old model value (i.e manish), whereas when fetch function executes, the change event is fired and the fetch callback gives me the new value (i.e logan).

Can someone help me in identifying what I am doing wrong here?

  • 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-14T22:11:47+00:00Added an answer on June 14, 2026 at 10:11 pm

    From backbonejs.org

    http://backbonejs.org/#Model-save

    Calling save with new attributes will cause a “change” event
    immediately, and a “sync” event after the server has acknowledged the
    successful change. Pass {wait: true} if you’d like to wait for the
    server before setting the new attributes on the model.

    Sounds like the server hasn’t returned that it is finished. Removing wait:true should make the changed event trigger.

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

Sidebar

Related Questions

Hopefully this is an easy question. I'm trying to learn backbone and i'm stuck
I am trying to learn backbone.js through the following example. Then I got stuck
I'm trying to learn backbone.js but the I'm stuck on fetching the json and
I'm trying to learn Backbone.js and I seem to be having an issue with
I'm trying to learn Backbone.js . I've been stuck on this for a whole
I've been trying to learn backbone.js these days. What I've is a model and
Trying to learn about php's arrays today. I have a set of arrays like
Im trying to learn a bit about c++ and have run in to some
Trying to learn R and am stuck on an autocorrelation example. I want to
Trying to learn Regex in Python to find words that have consecutive vowel-consonant or

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.