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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:07:18+00:00 2026-05-28T07:07:18+00:00

I have encountered a strange behaviour of the model validation in Backbone.js. When a

  • 0

I have encountered a strange behaviour of the model validation in Backbone.js.

When a model is first created, like

var foo = new Foo({
    bar: 42
});

Backbone invokes foo.set() passing as a parameter the given map {bar: 42}, as one can see from the source. In doing so, it also passes the options {silent: true}, as in the line

this.set(attributes, {silent : true});

This makes sense, since having silent === true avoids triggering the change events, which do not make sense in this context.

For some reason I cannot understand, though, silent === true also prevents validation; see the source at the line

if (!options.silent && this.validate && !this._performValidation(attrs, options)) return false;

So it appears model are never validated when they are created, but they usually are when some attributes are changed. Moreover, the presence of the validation is inextricably tied to the action of sending change events, which is something completely orthogonal.

Can anyone explain why this is so? What would be a clean and future proof way to fix this issue?

I could manually call _performValidation, but this has two drawbacks:

  • first, it is something I could simply forget
  • second, _performValidation is not part of the API and maybe it will change in future releases.
  • 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-05-28T07:07:19+00:00Added an answer on May 28, 2026 at 7:07 am

    Indeed I think that’s a bug on Backbone.JS.

    There is an open issue on GitHub here: https://github.com/documentcloud/backbone/issues/870

    Edit : In the new version 0.9.1 of Backbone.js, you can test if the model is valid with isValid method ( http://backbonejs.org/#Model-isValid )

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

Sidebar

Related Questions

I'm trying to learn python and have encountered some strange behaviour. I am experimenting
I encountered some really strange behaviour in Apache. I have a standard let PHP
I have encountered a strange behavior of BindingSource. First I set it's DataSource in
I have encountered a strange behaviour using dijit.form.select inside a tooltip-dialog. Here's a shortened
I have encountered strange problem. I have created simple Flash text field control and
I've encountered a strange thing. I have configured exception handling in struts 2.1.8 like
I have encountered a strange behavior while executing an sql query on the Oracle
We have encountered a very strange class not found problem in our web app
I have encountered a rather odd error that I do not understand. I created
I've encountered a strange behavior in __declspec(dllexport) in my project. I have a C++

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.