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

The Archive Base Latest Questions

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

I saw a few posts referencing a similar issue, but not quite the same

  • 0

I saw a few posts referencing a similar issue, but not quite the same thing.

Here is a snippet from the top of my routes file.

I’m wondering if the approach I’m using works to call global events on each of the routes. The events I’m using are pretty standard, simple events like clearing the #items container.

As you can see, I’m calling on the “all” event in the constructor, and then pointing to several methods defined in the routes file.

My question is, say I want the same global event on several screens; say, all of the “catalog” screens. I’ve been doing some strange and admittedly hacky tricks to get the ou

@routeName = route.split(":")[1]

# only substantiate the dropdown on User Catalog screen.
if @routeName is "catalogScreen" or @routeName is "catalogPDFScreen"

As I’m sure you can imagine, this is not ideal, nor is it particularly clean. I’m just trying to find ways to DRY up my router file to catch all of these global events, and this was the best I could think of.

routes:
  ""                                        : "homeScreen"
  "catalogs"                                : "catalogsScreen"
  "catalogs/:id"                            : "catalogScreen"
  "catalogs/:id/page/:page_id"              : "catalogScreen"
  "catalogs/:id/pdf"                        : "catalogPDFScreen"
  "catalogs/:id/pdf/page/:page_id"          : "catalogPDFScreen"
  "catalogs/:id/category/:category_id"      : "categoryScreen"
  "departments/:id"                         : "departmentScreen"
  "notifications"                           : "notificationsScreen"
  "settings"                                : "settingsScreen"
  "products/:id"                            : "productScreen"
  "catalog/:catalog_id/search/:search_query": "searchCatalogScreen"
  "search/:search_query"                    : "searchScreen"
  "login"                                   : "loginScreen"
  "members/:member_id/catalogs/:catalog_id" : "userCatalogScreen"
  "members/:member_id"                      : "profileScreen"
  ":user_name/:catalog_name"                : ""

#extends router class to allow storing of routes for a history
constructor: (options) ->
  @on "all", @storeRoute
  @on "all", @clearAlerts
  @on "all", @clearScroll
  @on "all", @setSearch
  @on "all", @setNav

Thanks in advance for anyone’s help on this! I’m growing more and more experienced with Backbone but I obviously have some stuff to learn.

  • 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-18T12:15:38+00:00Added an answer on June 18, 2026 at 12:15 pm

    In terms of DRY-ness in the route table itself, you can utilize the support for optional router parameters to combine the routes that share the same root, but different parameters:

    "catalogs/:id(/page/:page_id)"
    

    As for attaching common actions to some routes, but not all, there are a number of options. I think the cleanest way would be to split your router into multiple routers: CatalogRouter for the catalogs* urls, etc. This only makes sense if the routers would map naturally to your application structure.

    If you don’t want to split your routers, another way would be to trigger a custom event for the routes

    catalogScreen:(id, pageId) =>
      #normal route handling here
      @trigger "routed:catalog"
    

    And elsewhere:

    @on "routed:catalog", @foo
    @on "routed:catalog", @bar
    @on "routed:catalog", @baz
    

    Or if your event handlers don’t need the route arguments, you can use underscore’s compose for some syntactic sugar.

    @on "routed:catalog", _.compose @foo, @bar, @baz
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have looked around and saw a few posts on similar things but
I saw quite a few other posts related to EXC_BAD_ACCESS signals right on glDrawArrays,
I saw a few posts about get columns from subqueries, most of them suggest
I saw a few posts similar to my problem and tried the solutions offered,
I am not very good with STL and I saw few post similar to
I know that there's quite a few subjects similar to this one, but none
I saw a few posts on this but they were for PHP (I need
i saw few android apps got the interface similar with itune(as attached), user can
I saw some code when studying the open source project: here . But I
I have looked into a few posts and saw some related posts on it

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.