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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:04:37+00:00 2026-06-08T04:04:37+00:00

I have a Backbone model: var User = Backbone.Model.extend({ idAttribute: ‘_id’, url: ‘/api/user’, defaults:

  • 0

I have a Backbone model:

var User = Backbone.Model.extend({
  idAttribute: '_id',

  url: '/api/user',

  defaults:
    { username: ''
    },

  initialize: function () {
    console.log(this, this.isNew());
  }
});

Then I initialise the model and fetch the instance:

var user = new User();

user.fetch();

This works. If I inspect user, there is an id property. It exists on the server. However, for some reason user.isNew() is reporting true – even though it has an id property set (property as well as attribute). I need to update this model on the server but Backbone insists on sending POST requests, when I need PUT…

  • 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-08T04:04:39+00:00Added an answer on June 8, 2026 at 4:04 am

    initialize runs before the fetch is completed. isNew value will change until the server answer arrives. Listen for the change event on the model or pass a callback to the fetch call.

    var user = new User();
    
    user.fetch({success : function(){
      console.log( user.isNew() );
    }});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model and collection: var UserModel = Backbone.Model.extend({ url: 'api/user', idAttribute:'username',
In Backbone, I have a User model: var User = Backbone.Model.extend({ url: '/api/user' });
I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}
I have the following situation: var Task = Backbone.Model.extend({ initialize: function() { }, save:
I have two backbone models, loaded from server: var Model = Backbone.Model.extend({}); var SubModel
Using the following as an example: var Case = Backbone.Model.extend({ initialize: function(){ this.bind(error, function(model,
let's say I have : var Book = Backbone.Model.extend(); var Collection = Backbone.Collection.extend({ model:
I have created a model in backbone.js. var Content = Backbone.Model.extend({ // If you

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.