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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:45:10+00:00 2026-06-12T06:45:10+00:00

A Backbone.Model object maintains a ‘collection’ attribute. In the Backbone source code, we have

  • 0

A Backbone.Model object maintains a ‘collection’ attribute.
In the Backbone source code, we have :

var Model = Backbone.Model = function(attributes, options) {
   ...    
   if (options && options.collection) this.collection = options.collection;
   ...
}

The annotated source says nothing about that, and the documentation references only functions.
I guess it’s mainly used when deleting the model : the collection removes this model.

But what if the model belongs to many collections ? Is there a danger to use/override this collection attribute ?

  • 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-12T06:45:11+00:00Added an answer on June 12, 2026 at 6:45 am

    It’s used in two places (look a bit further down in the annotated source).

    • As you note, it’s used when a model is destroyed, to remove the model from the collection.

    Optimistically removes the model from its collection, if it has one.

    • In the url function, if the collection exists with a URL scheme, it uses that to construct a URL for the model.

    if you’re using Backbone’s restful methods, override this to change the endpoint that will be called.

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

Sidebar

Related Questions

I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
I have the following Parent Object: Context = { ContextModel: Backbone.Model.extend({ //model Code }),
My model and collection looks like this. var MyModel= Backbone.Model.Extend({ foo: function(){ alert(is not
I have created an object: var Person = Backbone.Model.extend({ defaults: { 'name': '', 'age':
I'm just beginning out on Backbone.js. Here's my code. $(function(){ //Backbone Model var Cat
var JavascriptHelper = Backbone.Model.extend(JavascriptHelper, {}, // never initialized as an instance { myFn: function()
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess
The code: var Appointment = Backbone.Model.extend({}); var appointment = new Appointment(); appointment.set('title', 'My knee
Assume that I have a backbone model that has a bunch of boolean attributes:
If i have this model: var myParentModel = Backbone.Model.extend({ defaults:{ parent1: null, parent2: null}

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.