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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:35:40+00:00 2026-05-24T15:35:40+00:00

Caveat: I’m working with a backend that I don’t have full control over, so

  • 0

Caveat: I’m working with a backend that I don’t have full control over, so I’m wrestling with a few considerations within Backbone that might be better addressed elsewhere…unfortunately, I have no choice but to handle them here!

So, my problem is that I’d really like to validate user input from a form (when I set values with it on Backbone models), but the models I receive from the API on newly created objects (via posts that ONLY accept a name, and ONLY return a name and object id) will fail my validation checks.

As example, when a new object is created in the database, two key fields are populated as empty strings (and so when Backbone hits the API and populates the models, it populates those keys with empty strings). When the user saves these objects back, post-edit, I’d like to force them to enter values for these two keys — which is very easy, given Backbone’s built in validation method.

The problem, of course, is that the validation is firing on both fetch->set (unwanted behavior) and set->save (desired behavior) — and so newly created models won’t load at all…Backbone collects them, validation fails, and errors fire.

So, my question is: is there a “Backbone-y” way to only validate the models on set->save, not on fetch->set? Could I use a specific trigger to work around this?

Any ideas would be greatly appreciated.

  • 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-24T15:35:40+00:00Added an answer on May 24, 2026 at 3:35 pm

    Backbone.Model.set won’t perform validation if you pass in { silent: true }, and fetch will pass any options through to set, so you could either override fetch or write your own fetchSilent method that passes that in an options object.

    However, you might run into a slight gotcha with Backbone.Collection.fetch, because when it receives attributes from the server, it doesn’t create the new models with set. Instead, it creates a new model with model = new this.model(attrs, {collection: this}); and then performs validation if there’s a validate method on the object.

    This is a little annoying. You can get around it by defining a parse method on your collection (if you’re using one) that creates a model silently (using {silent: true}), because when Backbone.Collection.add receives a fully formed Backbone model, it won’t run the validation. (see the _add and _prepareModel methods in the annotated source).

    It’s a little annoying that the collection works that way, but (for now at least) it is what it is.

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

Sidebar

Related Questions

Here's the caveat... If you have a table that has a single column and
[Caveat] This is not directly a programing question, but it is something that comes
Okay, this is just a minor caveat. I am currently working with the lovely
I'm working on a recurrence application for events. I have a date range of
I have a table of rows and columns on an HTML-based entry form that
I have two tables (A and G) in an Oracle database that can be
I have a table that has rows that are tagged by a class. These
Caveat: I have zero experience with MySQL. I've been given a series of files
Prelim caveat: I am very new to js and have mainly gotten by through
Caveat: I'm relatively new to coding as well as TextMate , so apologies if

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.