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 can.route.ready to false #298
Comments
I worry about basic apps. Those using can/control/route. On Mar 5, 2013, at 10:08 AM, David Luecke notifications@github.com wrote:
|
I'm having issues with this. CanJS is rewriting a route and escaping characters in it before i can stop it from running and doing so. It's extremely confusing because I haven't even told CanJS about any routes. In fact, removing all routing declarations and just loading CanJS on a page will alter my routes. Reasons it shouldn't be run by default:
|
You can make a download without can/route. That should solve the issues you're having. |
If I don't use the complicated routes with parameters, it doesn't happen, but then i also can't use those features. I'm using the AMD / RequireJS version, not the downloaded bundle. |
BTW, this bug can be seen in the TODO MVC example as well as my application. Here's a url to showcase what is happening. Watch the / after active to see what's happening. It gets encoded, and if it were a route, it would no longer match the route definition. You can actually see this by adding a number of characters like so: The semicolon will be encoded as well as the following = sign. |
What do you mean?
This issue is about can.route.ready being set to false. I'm not sure exactly what you are talking about. However, if you think there's another bug, can you create another issue? Also, can you carefully describe the bug? Ideally someone should be able to read the comment and know immediately what you are talking about. Thanks. EDIT: After spending some time trying to understand what you meant, I'm not even sure why https://github.com/addyosmani/todomvc/blob/gh-pages/architecture-examples/canjs/js/app.js#L6 can.route(':filter'); With just this one route, I would expect a hash like {filter: "foo/bar", route: ":filter"} I think you might be misunderstanding the idea behind can.route. can.route isn't as much about matching a hash as it is keeping state. say, for example there were two routes: can.route(':filter');
can.route(':filter/:something'); And the user set can.route w/ can.route.attr("filter","foo/bar") The hash would have to be set to {filter: "foo", something: "bar", route: ":filter/:something"} Basically, can.route does whatever it has to so the has represents one unique state. |
I've added another issue here per your request: |
You're absolutely right about that not being a route that the TODO MVC application is expecting. It wouldn't matter even if it were. CanJS shouldn't be manipulating those hashes. If it were actually expecting those routes, it wouldn't change the behavior of the page. The encoding would still happen and the routes would still break. |
If you are using the amd version, don't require 'can' directly, create a custom 'mycan' that requires only the modules you want. Also, you might be able to simply call can.route.ready(false) and never call |
That's not right. Check out the example in #330. I think the best solution for @jeffreytgilbert is simply not to load can.route if you aren't using it. Don't waste time loading code you aren't using. If we should call force a call to |
I'm currently using the routing for simple routes. Complex ones i'll have another pass at a few months down the road once i've finished everything mission critical on this project. On Mar 21, 2013, at 3:08 PM, Justin Meyer notifications@github.com wrote:
|
+1 I think we should start this off as Its a pretty common thing to need to do, shouldn't have to have the users doing it. |
Brought here from #475. Again, my big hesitation is that we will have to tell people they MUST call can.route.ready() to even use routing in the first place. The getting started guide will have can.route.ready(). |
The confusion/frustration from the automatic ready is likely related to #473 where ready is called once (before user has a chance to delay) and then again when jQuery's ready event is fired. Backbone and Ember both require an explicit call to start routing using In Ember's case it will start routing on DOMReady, but you can control that using I'd be fine with automatic route.ready on DOMReady if we added a |
I found it way harder having to explain (and document) when to use Plus personally when I do things like: var Router = can.Control.extend({
':type route': function() {
// do something
}
});
new Router(); I always want my route to fire even when the page is refreshed and the router is initialized and for that there is no way around having to call |
With 520f1b9, you MUST call can.route.ready. This will be part of 1.2. |
For 1.2 we should default
can.route.ready
to always befalse
and let the user initialize routing in any case.When to use
can.route.ready
and when not seems to cause quite a bit of confusion and in almost every case you need it anyway. Plus we can get rid of the rather hacky document ready detection (which had to be added because the document ready handler in libraries other than jQuery doesn't get called if the document is ready by the time it is attached).The text was updated successfully, but these errors were encountered: