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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:13:35+00:00 2026-06-14T06:13:35+00:00

I just started on learning BackboneJS and I’m doing a small sample document to

  • 0

I just started on learning BackboneJS and I’m doing a small sample document to test it’s way of working. But I have a hard time understanding it and at this moment it doesn’t make any sense at all 🙂

So, I have the next file structure :

/* application.js */
var Application = Application || {};

;(function ( $, window, document, undefined ) {

    new Application.ApplicationView();

})( jQuery, window, document );


/* sample.js */
var Application = Application || {};

;(function ( $, window, document, undefined ) {

    Application.ApplicationView = Backbone.View.extend({

    });

})( jQuery, window, document );


/* utilities.js */
var Application = Application || {};

;(function ( $, window, document, undefined ) {

Application.ApplicationUtilities = Backbone.Collection.extend({

    polyfillize : function(tests) {

        return _.each(tests, function(obj){
            console.log(obj);
            Modernizr.load([{
                test : _.reduce(obj.test, function(initial_value, current_value){
                    return initial_value && current_value;
                }, 1),
                nope : obj.polyfill,
                callback: function(url, result, key) {
                    console.log('Polyfill : ', [ url ]);
                }
            }]);
        });
    }

});

})( jQuery, window, document );


/* options.js */
var Application = Application || {};

;(function ( $, window, document, undefined ) {

Application.ApplicationOptions = Backbone.Model.extend({

    version : [ 1 ],

    prettify : true,

    libraries : {

        google_code_prettyfier : 'assets/js/libraries/google/prettify.js' 

    },

    dependencies : {

        google_code_prettyfier : function() {
            return Modernizr.load([{
                test : this.prettify,
                yep : [ this.libraries.google_code_prettyfier ],
                callback: function(url, result, key) {
                    return window.prettyPrint && prettyPrint();
                }
            }]);
        }
    },

    polyfills : {
        json_polyfill_url : 'http://cdn.chaoscod3r.com/code/polyfills/json3_polyfill.js',
        storage_polyfill_url : 'http://cdn.chaoscod3r.com/code/polyfills/localstorage_polyfill.js'
    }

});

})( jQuery, window, document );


/* polyfills.js */
var Application = Application || {};

;(function ( $, window, document, undefined ) {

Application.ApplicationPolyfills = Backbone.Model.extend({

    loadPolyfills : function() {
        return Application.ApplicationUtilities.polyfillize([
            {
                test        : [Modernizr.localstorage, Modernizr.sessionstorage],
                polyfill    : [Application.ApplicationOptions.polyfills.storage_polyfill_url]
            },
            {
                test        : [Modernizr.json],
                polyfill    : [Application.ApplicationOptions.polyfills.json_polyfill_url]
            }
        ]);
    }

});

})( jQuery, window, document );

Each model it’s placed in it’s own models folder, each collection in it’s collections folder and so on. Then I’m loading all the script in the DOM, first the collections, then the models, the views and last the application.js.

What I want to do is be able to use the collection as a collection of functions that I can use whenever I want in the Views or the Models, the options should be available on any level and in any of the collections / models / views. So it would be like my sample.js file will contain the main View which will initialize everything that needs to run onDOM load like loading all the polyfills if necessary, enabling the google code prettifier and so on.

Obviously nothing works at this state, so I would like someone more experienced to help me out if possible or maybe point to some tutorials that match what I’m trying to do right now 🙂

  • 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-14T06:13:36+00:00Added an answer on June 14, 2026 at 6:13 am

    You seem to be a little confused about what Backbone collections are all about.

    A collection in Backbone is a collection of (Backbone) models:

    Backbone.Collection

    Collections are ordered sets of models. […]

    When you say this:

    var C = Backbone.Collection.extend({
        method: function() { ... }
    });
    

    you’re creating a “class” and method will be available as an “instance method” after you create a new instance but you can’t call method directly on C because extend puts method on C.prototype for inheritance:

    C.method(); // This doesn't work, you'll just get an error.
    var c = new C;
    c.method(); // This works
    

    You say that

    it made sense to have it in a collection, a collection of utility functions 🙂

    but, unfortunately, just because something makes sense doesn’t mean that it really is sensible 🙂

    You don’t have any models for Application.ApplicationUtilities so it isn’t a collection in the Backbone sense. I think you just want to use an object as a namespace:

    Application.ApplicationUtilities = {
        polyfillize: function(tests) { /* ... */ }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Backbone.js, and have been working on (what else) a simple
I just started learning C but I don't understand this part of the code.
I´ve just started learning GWT and I´m trying to implement http://gwt.google.com/samples/Showcase/Showcase.html#!CwFileUpload and but failing
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
Just started learning Haskell. I have an empty source file with this inside: pe
I just started learning Zend. I managed to get the basic working (using zf
I just started learning SL. I have tried to resize all the elements inside
I just started learning Objective-C and OOP ... so I have very stupid question
I just started learning lisp in my class. I'm doing a homework assignment in
I just started learning C++ couple of weeks ago. So now I have this

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.