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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:28:49+00:00 2026-05-27T19:28:49+00:00

I have a model for which I would like to save only the attribute

  • 0

I have a model for which I would like to save only the attribute title. This is what I have tried:

myBook.model.save(['title']);

The problem is that request.body is the whole myBook.toJSON() object, instead of just the relevant attribute title. Is that by design, or am I doing something stupid?

  • 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-27T19:28:50+00:00Added an answer on May 27, 2026 at 7:28 pm

    It’s by design.

    save calls Backbone.sync to persist changes to your backend, which in turn does, among other things:

    if (!params.data && model && (method == 'create' || method == 'update')) {
      params.contentType = 'application/json';
      params.data = JSON.stringify(model.toJSON()); // <-- jsonifies the entire model
    }
    

    There are plenty of ways to override this behavior. You can give your model a sync method, in which case it will be called instead of Backbone’s default sync. Or you could just override Backbone.sync to do what you want.

    However, most server-side frameworks will be able to handle receiving the full JSON object and only updating the changed content. Why do you need to only send the changed attribute to the server?

    Side note: the first parameter to save should be a hash of attributes: so {title: newBookTitle} as opposed to ['title']. But I’m guessing that was probably just a quick example typo.

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

Sidebar

Related Questions

I have an application that allows users to save events. I would like to
I have a db model for which I would like to edit with multiple
I have a model that looks like this and stores data as key-value pairs.
I have various models of which I would like to keep track and collect
I have two models that I would like to present in a single Yii
I have multiple models which relate back to a single model. On save of
I have an [HttpPost] action method signature like this: [HttpPost] public ActionResult Edit(ExistingPostViewModel model)
So I have an observer which looks like this: class RecipeObserver < Mongoid::Observer def
I have an ActiveRecord model that has a long string field. Actually, this string
I have a model (share) in which I save who can edit a lesson.

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.