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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:23:16+00:00 2026-06-05T05:23:16+00:00

My problem is that i want to create object of model in javascript .I

  • 0

My problem is that i want to create object of model in javascript .I use backbone.js
I want to share model object globally because I need that object in many js files

 (function(){
     this.mymodel=Backbone.Model.extend({
            ----
            ----
     });
  return{
            var colobj = new mymodel;
  }
})

and I am sharing “colobj” object in another js file as follows

(function(){
     var collectionobj = new colobj;
 });

but this gives me error what is wrong in this example

  • 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-05T05:23:17+00:00Added an answer on June 5, 2026 at 5:23 am

    First of all, you should change this line :

    var colobj = new mymodel;
    

    to

    var colobj = new this.mymodel;
    

    The thing is that mymodel was undefined and that may have been the roots of your problem.

    In addition, your first colobj is an instance of your model, thus it is an object and not a constructor. That’s why the second time you try to instantiate it :

    var collectionobj = new colobj;
    

    it throws an error, because the browser thinks you’re doing something like :

    var collectionobj = new (new mymodel);
    

    I suggest you pass only the model definition the from one closure to another:

    //...
    return{
            var colobj = this.mymodel;
    }
    //...
    

    UPDATE
    I’m very surprised to see that I’ve missed this before.
    You are returning an invalid object :

    {var colobj = new mymodel;}
    

    I think that you probably meant to return an object that hash a colobj property with the value of your model. If that’s the case, all you have to do is return this object :

    {colobj : this.mymodel};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a crawler with C#. The problem is that some websites
Problem I want to create an application that can be extended somehow by programmers.
My problem is that I want to redirect via JavaScript to a directory above.
I want to create an object that acts as a specific class, such as
I want to create a model that doesn't map to a database table. Instead,
I use embedded SVG in XHTML and want to create animations from Javascript, but
with my RCP program I have the problem that I want to have more
My problem is that I want to have a tab bar view with its
My problem is that I want to rotate the UIImageView of a UIButton .
My Problem is that I want to check if the Arrow up or down

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.