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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:19:37+00:00 2026-06-18T11:19:37+00:00

I am currently looking at Backbone as a way to organise our javascript files

  • 0

I am currently looking at Backbone as a way to organise our javascript files and create a clean structure for our code.

My question is mainly a “Best Practice” question.

The library works great and I have successfully setup my structure with AMD and requirejs. My question relates to a couple of utility files that I am running. One gets data from an XML document and converts it to a json data object (so data can be localised). The other is a utility that loads and connects to Facebook. I have created both of these as ‘Models’.

Arguably these models should probably be “Controllers” as they connect to services but these need to be called without the need to browse to a hashbang in a router (or controller) file.

Should I be extending backbones model for these two utility files or is there something else I should be doing to implement utility files like this ?

  • 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-18T11:19:38+00:00Added an answer on June 18, 2026 at 11:19 am

    There’s nothing objectively wrong with using Backbone.Models for this purpose, but regardless it feels fishy. Model comes with extra baggage which doesn’t belong in a “service” or “utility” type class.

    Instead I’ve defined a more generic, evented base class for functionality that doesn’t quite fit the Backbone Model-View-Collection-Router paradigm.

    define(['backbone', 'underscore'], function(Backbone, _) {
    
      var Class = function() {
        this.initialize.apply(this, arguments);
      };
    
      //give Class events and a default constructor
      _.extend(Class.prototype, Backbone.Events, {initialize: function() {}});
    
      //copy the extend feature from one of the backbone classes
      Class.extend = Backbone.Model.extend;
    
      return Class;
    });
    

    The class behaves like other Backbone objects, in that it can be extended, its instances have a initialize constructor method and they support events. One of your examples, the localization service, could look something like:

    var LocalizationService = Class.extend({
      initialize: function(url) {
        this.url = url;
        this.fetch();
      },
    
      fetch: function({
        var self = this;
        $.ajax({
          url:this.url,
          success: function(response) {
            self.response = response;
            self.trigger('fetch:complete', self, response);
            //etc...
          }
        });
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently looking for a way to remove fullstops from a string in
I'm currently looking at ways to allow people to select multiple files at once
I am currently looking a way to have my database under version control. To
I'm currently looking at a piece of code from the excellent Rails-composer and I
Our business is currently looking at developing iPhone versions of applications we build for
I'm currently looking for a way to move the mouse in wpf. All I
I am currently looking for a way to send an email notification with WordPress
I am currently looking for a way where I can build a lambda expression
I'm currently looking for a javascript to do a math calculation for me. I'm
We are currently looking at either using CAB or MEF for our next application.

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.