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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:58:25+00:00 2026-06-02T22:58:25+00:00

I just upgrade a site I worked on from Backbone.js 0.5.3 to Backbone.js 0.9.2

  • 0

I just upgrade a site I worked on from Backbone.js 0.5.3 to Backbone.js 0.9.2
When I did I get an undefined for my options parameter that I use in my models initialize method. What has changed from V.5 to V.9

initialize: function( options ) {enter code here
}

Ok here is my model structure. Everything works fine in 0.5.3 but when I use 0.9.2 options no longer works.

this.myModel = Backbone.Model.extend({

        defaults: function() {
            return {
                maxDays: 7,
                index: 0

            };
        },

        initialize: function( options ) {

        }

})



this.model = new myModel();

In version 0.5.3 options will show all the attributes that were set in the defaults object.
but in version 0.9.2 this no longer works it returns undefined.
I can not post a link because of the client sensitivity.

  • 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-02T22:58:28+00:00Added an answer on June 2, 2026 at 10:58 pm

    The signature of initialize remains unchanged I believe from 0.5 to 0.9. However, you only get options passed in if you pass them to the constructor. Check out the annotated source for Backbone.Model. Whenever you instantiate a new model instance, the constructor does this:

    this.initialize.apply(this, arguments);
    

    So whatever you pass to the constructor gets passed unmodified to initialize. So look in your code for cases where you are instantiating a new model instance but not passing 2 arguments (attributes and options).

    Based on your code sample, you now need to define initialize as taking 2 parameters: attributes and options and when creating your models, if you want to just pass options do:

    var model = new Model(null, options);
    

    or

    var model = new Model({}, options);
    

    I think the specific change that broke your code is the switch from calling initialize with explicit arguments in 0.5.3 to using apply and arguments in 0.9.3 like this:

        this.initialize.apply(this, arguments);
    

    So in 0.9 you can get access to your defaults through this.attributes, but they won’t come in as a function parameter unless they came in as a parameter to the constructor function.

    var MyModel = Backbone.Model.extend({
        defaults: {x: 42, y: 43},
        initialize: function(attributes, options) {
            console.log(arguments, attributes, this.attributes);}
    });
    var m = new MyModel();
    

    That will log [], undefined, Object since arguments is empty, attributes is undefined since nothing was passed to the constructor, but the defaults HAVE been set in this.attributes and are there for you to use.

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

Sidebar

Related Questions

I'm just begin upgrade my asp.net site from Webform to MVC 2. So far
In drupal, keep getting an upgrade message all over site from htmlpurifier that a
I just upgraded my site from ASP.NET 3.5 to 4.0. I've been working through
I've just received an assignment to upgrade an old Delphi 3 project that I
With my database upgrade scripts, I typically just have one long script that makes
I just upgraded from Rails 3.0.3 to 3.2.1. The upgrade went smoothly on my
I just upgraded my Web Site project from 2.0 to 3.5 to take advantage
I have an old drupal site that I'd like to upgrade, but I need
I was asked to fix a site that was fine just days ago and
I've just upgrade my rails application from the 3.0.7 version to the release candidate

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.