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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:29:27+00:00 2026-06-15T03:29:27+00:00

I have a form that create a model for a collection. That fires an

  • 0

I have a form that create a model for a collection. That fires an add event to the collection. I have that binded to a method:

this.collection.bind('add', this.addOne, this)

fires…

addOne: function(tenant) {
   var self = this
   var collection = this.collection

   var view = new TenantView({model: tenant,collection:collection});
   self.$el.append(view.render().el);
}

The create syncs it to the database but, the new appended view still isNew to backbone since it hasn’t fetched the collection and grabbed the id for the new model.

My question, how can I grab the synced model from the server (that has the id and isn’t isNew) without fetching the entire collection then append it?

  • 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-15T03:29:29+00:00Added an answer on June 15, 2026 at 3:29 am

    Use the sync event instead of add…

    this.collection.bind('sync', this.addOne, this);
    

    The add event gets fired immediately when calling create; but sync gets fired once the server has responded to the create method, so it should include the correct model id.

    You can also wait for the server’s response, before adding the model to the collection — to do that use wait: true in create‘s options hash: collection.create({ ... }, { wait: true }).

    Creating a model will cause an immediate “add” event to be triggered on the collection, as well as a “sync” event, once the model has been successfully created on the server. Pass {wait: true} if you’d like to wait for the server before adding the new model to the collection.

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

Sidebar

Related Questions

I have a view which handles a form. This form has an event that
I'm following this rails cast to create a nested form: http://railscasts.com/episodes/196-nested-model-form-part-1 I have a
if i have created a view model and have a partial form that is
I have an admin form that lets users create entities that require an image.
I have a form. In that form I create an instance of a class
I have a web form that uses if statements to create a string of
I have a create action for a form that potentially generates errors (i.e. first
I'm have a fair complex Form that I am trying to create in Play
I have a form on a page that a user can use to create
i have asked to create a module that will record video messages form the

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.