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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:48:42+00:00 2026-06-05T00:48:42+00:00

I am setting up the backbone sync mechanism and am a bit confused where

  • 0

I am setting up the backbone sync mechanism and am a bit confused where to generate the id’s for the models.

When I create a new model, should backbone be generating and setting the id, or am i supposed to implement an id generation method, or is there some sort of mechanism where I “PUT” the data to the server, which generates the id and returns a model with the id?

  • 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-05T00:48:45+00:00Added an answer on June 5, 2026 at 12:48 am

    or is there some sort of mechanism where I “PUT” the data to the server, which generates the id and returns a model with the id?

    Kind of. When you call the save method of your model, backbone make a POST XHR and your application server should respond with JSON contains an id.
    You can see an example here: http://addyosmani.com/blog/building-backbone-js-apps-with-ruby-sinatra-mongodb-and-haml/

    Quoting from the link:

    post '/api/:thing' do 
      # parse the post body of the content being posted, convert to a string, insert into 
      # the collection #thing and return the ObjectId as a string for reference 
      oid = DB.collection(params[:thing]).insert(JSON.parse(request.body.read.tos)) 
      "{\"id\": \"#{oid.to_s}\"}" 
    end
    

    If you don’t know Ruby keep in mind what the last expression that is evaluated is automatically returned by the method.

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

Sidebar

Related Questions

When I pass {silent:true} while setting an attribute in a Backbone model, why doesn't
Setting up new git installations. On one Windows laptop, I'm running (under cygwin): git
Lets have the following code : ( function($) { TeacherModel = Backbone.Model.extend({ defaults :
I have noticed that when multiple attributes of a Backbone model are set like
Setting up a new database that has a comments table. I've been told to
I have a backbone model called Member - this contains membership data such as
I'm using HAML to generate templates for a Backbone.js app. I need to be
I have been looking at backbone.js/spine.js and I like the idea of just setting
Setting role when creating new user with ASP.net MVC I am looking at the
I am having difficulty getting the create function of backbone.js to work. My main

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.