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

PathJS Wildcard #63

Open
jacobfernandez opened this issue Jun 7, 2013 · 8 comments
Open

PathJS Wildcard #63

jacobfernandez opened this issue Jun 7, 2013 · 8 comments

Comments

@jacobfernandez
Copy link

I want to execute a function if the url matches the defined wildcard structure. For example, I want to run alert("hello world") if the url matches any of these: http://example.com/foo/x, http://example.com/foo/y, http://example.com/foo/z. I don't want to write this code for every route. Is there something like
Path.map("#/foo/*").to(function() {
alert("hello world");
});
?
Thanks

@yckart
Copy link

yckart commented Jun 7, 2013

You can use "#/foo/:page". Take a look at the tests to find out more: https://github.com/mtrpcic/pathjs/blob/master/tests/path.js.test.html#L80-94

@jacobfernandez
Copy link
Author

On 6/7/2013 12:05 PM, Yannick Albert wrote:

You can use "#/foo/:id". Take a look at the tests to find out more:
https://github.com/mtrpcic/pathjs/blob/master/tests/path.js.test.html#L80-94


Reply to this email directly or view it on GitHub
#63 (comment).

Hi Yannick,

Thanks for the reply. I tested what the example does but I can't get it
to work. And to extend the example, how could I achieve it with
#/foo/x/a, #/foo/x/a/b/c, #/foo/x, #/foo ? I want to execute it for
every route with #/foo*. Thank you so much.

@yckart
Copy link

yckart commented Jun 7, 2013

@jacobfernandez
Copy link
Author

I know how to use parameters, I have already built numerous apps using pathjs. What I am looking for is to how to execute a function all routes with #/foo. All under the foo route should run the function.

@jacobfernandez
Copy link
Author

It is working now with this code

Path.map("#/foo/(:x)").to(function() {
alert("Hello World!");
});

And the reference link should be https://github.com/mtrpcic/pathjs/wiki/Using-the-Hashtag#optionaldynamic-routes

@yckart
Copy link

yckart commented Jun 7, 2013

Ok, good to know :) Can this issue be closed?

@jacobfernandez
Copy link
Author

Issue can be closed now. Thanks for the responses

@str
Copy link

str commented May 29, 2017

@jacobfernandez Were you able to detect any amount of params, like when you said:

how could I achieve it with #/foo/x/a, #/foo/x/a/b/c, #/foo/x, #/foo ?

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