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

Creating a Path Mapping for a query string? #7

Closed
bhellman1 opened this issue Jun 19, 2011 · 2 comments
Closed

Creating a Path Mapping for a query string? #7

bhellman1 opened this issue Jun 19, 2011 · 2 comments

Comments

@bhellman1
Copy link

Any examples available on how to create a path mapping for a url with a query string.

Example URL:

http://localhost:3000/#!/rooms?_=1308513473427&page=2

I'm trying to create a mapping that then returns 2

This does not appear to be taking:

Path.map("#/rooms?:id").to(function(){

});

thanks

@mtrpcic
Copy link
Owner

mtrpcic commented Jun 20, 2011

Query strings are for passing parameters to the server, and have no bearing on the client-side routing available via the hash-tag. To get something working like a "page index" system, which it appears you're trying to do, you can do the following with the latest version of PathJS:

Path.map("#!/rooms/:room_id(/:page)").to(function(){
    var page_index = this.params["page"] || 1;
});

The above example uses the new Optional Parameters feature of PathJS. Using this feature, you can access a route like this:

http://www.yoursite.com/#!/rooms/1308513473427    // Access with now page index passed in
http://www.yoursite.com/#!/rooms/1308513473427/2 // Explicitly pass the index in.

In the code example above, you see that I set a default page index if none was passed in.

@mtrpcic mtrpcic closed this as completed Jun 20, 2011
@bhellman1
Copy link
Author

Thanks mtrpcic

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

2 participants