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

Multiple routes trigger first one to fire multiple times #30

Open
rvision opened this issue Jul 30, 2014 · 7 comments
Open

Multiple routes trigger first one to fire multiple times #30

rvision opened this issue Jul 30, 2014 · 7 comments

Comments

@rvision
Copy link

rvision commented Jul 30, 2014

I have a following code:

routie('search/:text', function(text) { ... });
routie('view-group/:id', function(id) { ... });
routie('view-test1/:id', function(id) { ... });
routie('view-test2/:id', function(id) { ... });

When reloading a page, first handler ('search/:text') when route is matched is fired 4 times, for each route declared. If I remove view-test1 and view-test2, it is fired 2 times.

Is this a serious bug?

@rvision
Copy link
Author

rvision commented Jul 30, 2014

It seems that this happens in

-latest Firefox (v31.0)
-IE 11

works fine in Opera

@ollyoechsle
Copy link

By coincidence I also noticed this today. Looking at the source the way to do it is to call routie once, passing in an object if there are multiple routes.

routie({
'search/:text': function(text) { ... },
,'view-group/:id', function(id) { ... },
,'view-test1/:id', function(id) { ... },
,'view-test2/:id', function(id) { ... }
});

Would it be possible to make this clearer in the docs? Perhaps Routie could also print a console warning stating that init should only be called once?

Otherwise it is a great product, and I use it often. Thank you for developing it.

@rvision
Copy link
Author

rvision commented Jul 30, 2014

Doesn't work for me, I need routing in multiple modules...

@carsonwright
Copy link

I'm having this problem too, I'm on chrome, and the first time it loads it tries to execute 3 times.

@rubenspgcavalcante
Copy link

I need to declare each one in the index of each module.
Each time I declare a route, the other ones already declared is fired by the number of declared routes.
Ubuntu Firefox v32.0

update:
I've made a pull request. After all routie declarations, with last param (forceCheck) as false, explicitly call the reload using apply. e.g.:
routie('search/:text', function(text) { ... }, false);
routie('view-group/:id', function(id) { ... }, false);
routie('view-test1/:id', function(id) { ... }, false);
routie('view-test2/:id', function(id) { ... }, false);
routie.apply();

@NicholasEymann
Copy link

I have opened a pull request that fixes this issue. #47

@CtrlC-Root
Copy link
Contributor

@NicholasEymann Thanks! I'll take a look at it soon and get back to you in the actual pull request.

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

No branches or pull requests

6 participants