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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:19:26+00:00 2026-06-04T07:19:26+00:00

I use Backbone.js to create a web app,all the view,collection and model write into

  • 0

I use Backbone.js to create a web app,all the view,collection and model write into one js file,it success!

now I want separate them to different js files,just like:

<script type="text/javascript" src="js/layermanagemodel.js"></script>       
<script type="text/javascript" src="js/layermanagecollection.js"></script>  
<script type="text/javascript" src="js/layermanageview.js"></script>    
<script type="text/javascript" src="js/boot.js"></script>

and load model code in jquery load:

$(function(){
    //Model
        var manageModel = Backbone.Model.extend({
                default:{
                    'selectedId':'unknow'
                },
                selectLayer:function(uuid){
                     this.set({"selectedId": uuid});
                },
                delLayer:function(){

                }
        }); 
})

but the firebug tell me bug:

manageModel is not defined
[Break On This Error]   

model: manageModel

in collection file

why if separate them to different file ,they could not recognize each other?how can I solve this problem?Or what is right load order?thank you

  • 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-04T07:19:27+00:00Added an answer on June 4, 2026 at 7:19 am

    Once you add the function wrappers:

    $(function() {
        // ...
    })
    

    You’ve introduced new scopes and all the vars declared inside those functions are only visible within those functions. You can get around this by making them global (i.e. properties of window):

    $(function(){
        window.manageModel = Backbone.Model.extend({
            //...
        });
    });
    

    or better, introduce an application namespace:

    $(function(){
        window.app = window.app || { };
        window.app.manageModel = Backbone.Model.extend({
            //...
        });
    });
    

    and then refer to things through app like app.manageModel:

    $(function(){
        window.app = window.app || { };
        window.app.someCollection = Backbone.Collection.extend({
            model: app.manageModel,
            //...
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i create/convert this script into model in Backbone that can use SignaR
I'm using WCF to create the REST backend for an app using backbone. WCF
I know that I can use jQuery to access the view's element in backbone.js
I want to create a custom wordpress plugin. I want to use backbone.js. I
I am attempting to create a Backbone.js view based on a Twitter bootstrap-modal, which
I use the standard web.config 'mailSettings' as the backbone for my ASP.NET emails. However,
Is it possible to use Backbone.js and jquery.datalink.js together to link a Backbone model
Some of my Backbone models should always use POST, instead of POST for create
I use backbone.js' s model. When i save the model, it sends HTTP OPTIONS
I've decided to use MVC Pattern on my site. So, now I use Backbone.js

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.