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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:16:51+00:00 2026-06-04T04:16:51+00:00

Strangely I noticed that the model previous method is not working the way I

  • 0

Strangely I noticed that the model previous method is not working the way I thought.. it keeps returning the same value as the get. I think that something is wrong with my code or backbone.js is not upgrading the this._previousAttributes when change event is fired.

model = new Backbone.Model()

model.set({attr1: 123})

alert(model.previous("attr1"))  //alert 123 instead of undefined
alert(model.get("attr1"))

model.set({attr1: 312})

alert(model.previous("attr1"))  //alert 321 instead of 123
alert(model.get("attr1"))

http://jsfiddle.net/wLKBk/

What am I doing wrong?

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

    The previous method is only useful while a "change" event is happening:

    previous model.previous(attribute)

    During a "change" event, this method can be used to get the previous value of a changed attribute.

    The previous method is only useful inside a "change" event handler; similar things apply to hasChanged, changedAttributes, and previousAttributes.

    You’re trying to use previous when you’re not inside an event handler so you get nonsense. If you want to know what has changed in a model and you need to know outside of "change" event handlers, then you’ll have to track it yourself.

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

Sidebar

Related Questions

Just today I noticed a strange behavior in an object model that was previously
While working with ASP.NET MVC, I have noticed that exception messages issued by the
I have noticed that there are strange requests to my website trying to find
i am trying to load md2 files in opengl but i noticed that most
I'm using gcc 4.6 in c++0x mode. I've noticed I don't seem to get
I'm currently employed at a small ASP.NET/MS-SQL shop. My team has noticed that a
I noticed while testing my library that VS2010 will throw an error if I
I've got an object model that is persisted using Seam and JPA (Hibernate). It
When parsing dates in different time zones I noticed that NSDateFormatter produces strange results
I've noticed that PHP's current() and key() array functions ( like other array-pointer functions

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.