Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default path #10

Closed
aaronchi opened this issue Sep 25, 2011 · 4 comments
Closed

default path #10

aaronchi opened this issue Sep 25, 2011 · 4 comments

Comments

@aaronchi
Copy link

In some previous documentation it seemed like there a default function you could set if no paths matched. I want to use this but it seems to be missing in the current version. I tried using rescue for this but it doesn't work in the same way (doesn't set the window location)

Is there any way to apply a default function to all paths?

Maybe one way to do this is to include the same wildcard functionality as in rails routes using *

Path.map("/*path")

@mtrpcic
Copy link
Owner

mtrpcic commented Sep 25, 2011

You can specify a default action that will be called if none are provided upon page load via the Path.root, like so:

Path.root("#/index");

Then you can specify that as an action:

Path.map("#/index").to(function(){
    // Your default code here
});

If a user lands on your page with no route specified, it will automatically go to the root path. This can be anything; you just need to assign an action to that route via the usual Path.map methods.

Hope my answer was helpful. If so, please ask again, and/or close the question.

@mtrpcic
Copy link
Owner

mtrpcic commented Oct 29, 2011

I have not heard any issue with this in over 1 month. I take it my comment solved the problem. If there are any further issues, please feel free to open a new issue.

@mtrpcic mtrpcic closed this as completed Oct 29, 2011
@alexdmiller
Copy link

Can you explain how to use Path.root to achieve the same functionality presented in this tutorial?

http://mtrpcic.net/2011/02/fragment-uris-theyre-not-as-bad-as-you-think-really/

@mtrpcic
Copy link
Owner

mtrpcic commented Mar 12, 2012

That post doesn't make use of path.root, it uses the Path.default function. You'll have to have accompanying server-side code to modify the returned HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants