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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:18:23+00:00 2026-06-12T18:18:23+00:00

I am starting developing an application with backbone+require. I want to share a same

  • 0

I am starting developing an application with backbone+require. I want to share a same instance of a Model between several views. I have defined the model as a singleton, and thus all the views access the same instance of the model.

I have evaluated two options:

1.Use Events with the instance of the Model as a parameter to communicate views

2.Share the same instance of the model between views.

I have chosen the second option, adding a new line to my Model:

define(['Underscore','Backbone'], 
function(_, Backbone) {
    var Experience = Backbone.Model.extend({
        defaults: {
            'id' : 1,           
            'date' : '2012-10-11 '
        }
    });
     if (this.model === undefined)   return  new Experience();
});

And then I bind the model to my views

define([ 'jQuery','Underscore','Backbone','models/experience'
], function($, _, Backbone, Experience){
  var MyView1 = Backbone.View.extend({     
            initialize: function () {               
                this.model = Experience;
                ....

This way, all the views with this model share it.

Is there a better way for sharing instances of a model in backbone? Would it be better to use events and the instances as parameters?

  • 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-12T18:18:24+00:00Added an answer on June 12, 2026 at 6:18 pm

    IMHO a Singleton is the way to go in your case.

    Passing instances to views would be useful in case of a very generic view that is shared between a lot o models and as far as I can see it’s not your case.

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

Sidebar

Related Questions

I am starting developing a new application based on fragments. What I want to
I'm developing a web application for a new service, starting from Firefox 3.5. The
I'm just starting web-developing now (I do have experience with C#). And I've seen
I am developing application in which my thread is starting when connectionDidFinishLoading. - (void)connectionDidFinishLoading:(NSURLConnection
I'm starting developing applications for iPhone. My idea is to develop a application like
I'm starting developing using Zend Framework and I have a question about routes. Is
We're developing a SaaS application, which, among other things, has to have email integration:
I am developing an application that will have to run on both Windows and
I am developing a WinForms application and starting to dig into the reporting functionality.
I'm starting developing a Facebook app with PHP SDK, I have a two doubs

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.