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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:06:24+00:00 2026-06-06T19:06:24+00:00

In my Backbone application I have a main view that shows previews of posts.

  • 0

In my Backbone application I have a main view that shows previews of posts. When the user clicks on a post, the post is expanded in an overlay and the URL is changed to reflect that post. While the post is expanded the user may do something that triggers a call to the server that needs to happen at the root context. The problem is that when the post is expanded, the server call that needs to happen at the root context happens from the post context instead. Here’s the order of operations:

  1. Page is loaded with main view url: http://localhost:8080/my-web-app/
  2. User clicks post, overlay is shown, url updated to: http://localhost:8080/my-web-app/posts/1
  3. User clicks something that triggers a call to server. Url is: http://localhost:8080/my-web-app/posts/1/load, which is wrong.

In the example above, the load operation needs to happen from the root context: http://localhost:8080/my-web-app/load

I’ve tried changing the url property for my models, collections, etc. to include a leading /, but this removes the “/my-web-app/” context (the url becomes http://localhost:8080/load), which is necessary in my test environment. This would work fine in a production environment, of course.

To get around this, I have set the Backbone.history root option to be “/my-web-app/” and have overridden every url property to be as follows:

url: function() {
  (Backbone.history.options.root != undefined ? Backbone.history.options.root : "") + "load";
}

While this approach works, it is a pain in the ass to override every url function like this… not to mention, it feels hacky. It is also totally unecessary code for a production environment. Is there a more elegant way to manage this so that it works in both test and production environments?

Thanks!

  • 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-06T19:06:26+00:00Added an answer on June 6, 2026 at 7:06 pm

    Application routing shouldn’t differ on dev environment and production. This will always bring trouble at some point.

    Assuming you’re using Apache server on your localhost, you can make a virtual host of your choice and make /my-web-app/ available on the /.

    First, add a domain name to your /etc/hosts file and point it to 127.0.0.1, like that:

    127.0.0.1   mywebapphost
    

    and then add a virtual host to your Apache vhosts.conf

    <VirtualHost *:80>
        DocumentRoot "/Users/someone/Sites/my-web-app/" # absolute directory of your webapp
        ServerName mywebapphost
    </VirtualHost>
    

    And you’re done! Your webapp is available on //mywebapphost:8080 and all routing is identical to your production environment.

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

Sidebar

Related Questions

I have a Backbone.js application that allows users to create graphs based on large
I have created a Backbone.js/Require.js application that dynamically loads HTML templates to use as
Say I have a Backbone application with a Posts collection. All posts belong to
I have a Backbone application that appends elements to the DOM. When I log
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
My current backbone application has a url: localhost/#users Is there a way to access
I need to check that a user have logged in and been authenticated before
I have a backbone application which, upon load, needs to fetch data from four
I use Backbone.js and jQuery 1.7 in my application and I have some problems
The Application Layout I have an application, with a sidebar that holds many items

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.