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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:34:43+00:00 2026-05-24T17:34:43+00:00

I am having difficulty getting the create function of backbone.js to work. My main

  • 0

I am having difficulty getting the create function of backbone.js to work. My main question, is where do nextModel, resp, xhr come from?
I thought it should be doing coll.add(model) (‘coz we’re trying to add a model to the collection).

Thank you.

create : function(model, options) {
    var coll = this;
    options || (options = {});
    model = this._prepareModel(model, options);
    if (!model) return false;

    var success = options.success;

    options.success = function(nextModel, resp, xhr) {
        coll.add(nextModel, options);
        if (success) success(nextModel, resp, xhr);
    };
    model.save(null, options);
    return model;
},

UPDATE:
This is what I learned following clues from shesak. I tracked it down, from Create to Save then to Backbone.sync. The options.success at the end will correspond to this in Jquery

success(data, textStatus, jqXHR)Function, Array

A function to be called if the request succeeds. The function gets passed three arguments:

  • the data returned from the server, formatted according to the dataType parameter
  • a string describing the status
  • and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object.

As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. Which means, nextModel would come from the data of success(data, textStatus, jqXHR).

  • 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-24T17:34:44+00:00Added an answer on May 24, 2026 at 5:34 pm

    The options object, along with the success callback, are passed to Backbone.Model#save, which saves a copy of the success callback, overrides it with its own callback and calls Backbone.sync, which eventually calls $.ajax with the entire options object. Its jQuery’s (or Zepto’s) code that eventually calls the (overridden) options.success with the JSON response from the server.

    The overridden success callback set()s the response from the server on the model (the server, after saving the model, can return either the entire model of it or just some of the attributes in JSON format. This is done to allow the server to modify or normalize the model when saving it [like adding the newly created ID]), and passes the changed model (that changed model is what being referred to as nextModel) back to the saved copy of the original success callback (the one defined in Backbone.Collection#create), which adds that nextModel (as passed from Backbone.Model#save, after being modified by the JSON response from the server) to the collection.


    If you just want to add a model to the collection, without saving it in persistent storage by the server, call Backbone.Collection#add directly instead of create.

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

Sidebar

Related Questions

I'm having difficulty getting the Model Binder to work. I thought it was the
I'm having difficulty getting XQuery to work. I downloaded Saxon-HE 9.2. It seems to
I'm having great difficulty getting my Android application to play videos from the SD
I'm having a lot of difficulty getting strophe's 'attach()' function working. I am working
I'm having difficulty getting HTML.ActionLink() create correct links. When I am at http://localhost:49242/ My
I'm having difficulty getting the awk command inside a bash script to work. The
I'm following a tutorial on php, and am having difficulty getting this to work.
I'm having some difficulty getting this script to execute properly. The create_rss function does
I'm having difficulty getting widgets in a QDialog resized automatically when the dialog itself
I'm having an extremely difficulty time getting the flowplayer to show up and 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.