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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:04:41+00:00 2026-06-01T15:04:41+00:00

I am using the backbone-boilerplate, which you can find here . I was wondering

  • 0

I am using the backbone-boilerplate, which you can find here.

I was wondering how to add global functionality, which isn’t explicitly tied to any specific collection, model, view, etc. An example would be a ‘logout’ function, which might look like this:

var logout = function(){
  // Clear Favorites
  // Handle asynchronous logging (all in-app logs are sent to the server at logout)
  // Redirect to the login page
  // Do other cleanup
}

Basically, this will handle numerous models/collections, including Favorites, Events, Logs, Users, and the application Router

If you look at the main.js file in the backbone-boilerplate, I have been adding these functions at the top (line 13) like this:

function(namespace, $, Backbone, Example){

  // BEGIN MY APP LOGIC
  namespace.app.logout = function(){
    // Do logout here
  };
  // END MY APP LOGIC

  var Router = Backbone.Router.extend({

This works fine, but the application logic can quickly grow out of control. My question is, what would be a better way to organize this code? If I had a Utils module and loaded that Utils module in, would it make more sense?

Cheers!

  • 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-01T15:04:42+00:00Added an answer on June 1, 2026 at 3:04 pm

    TLDR: http://addyosmani.github.com/backbone-fundamentals/ Advanced section.

    Make it possible, then make it beautiful, then make it fast.

    As you grow your app and make things work (possible), it will become apparent which functions belong together. Separate them into modules accordingly (beautiful).

    I use require.js, but not backbone-boilerplate (bb has an AMD branch as well). The way I have organized my app is exactly as you describe, I have a utils module that has general purpose app stuff. I then add Auth, Notification, and Date formatting stuff to the utils module. I then include the utils module wherever I’m lazy and want all my util functions available.

    Since they are all just modules/mixins, I can also include the auth/notification/date modules in any single module I need them in.

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

Sidebar

Related Questions

just wondering if there could be any issue building a shopping cart using Backbone.js
I'm currently using backbone boilerplate and running it on my MAMP server localhost. I
I am using backbone.js here is my scenario Lets say I have a view
Trying to get my head around backbone.js. This example is using Backbone Boilerplate and
I'm using backbone with the backbone-rails gem which does its own templating and project
I am building an application using the Backbone Boilerplate , and am having some
I am using backbone.js on a rails backend with HAML Coffee , which is
I'm using Backbone along with Mustache, how can I detect when a view is
I'm using backbone boilerplate to render my templates, its fetchTemplate method caches the rendered
I'm working on an app that uses Backbone and RequireJS (using the Backbone boilerplate).

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.