Closed mathieutozer closed 10 years ago
Yes, this is possible, but I don't currently have an accessible way to do it.
In the current version of RouteCore, the best mechanism is to do the following:
RouteCore.context().redirect(target_url)
You can get target_url
in a few ways, the best way would be to call Routes.project
Routes.project(project) // Would return '/projects/PROJECT_HERE'
So put them together and you get:
addProject: function() {
var project = Projects.insert({name: "new proj"});
RouteCore.context().redirect(Routes.project(project)); // eww
}
I will release an update soon with new syntax, probably RouteCore.go(url)
or maybe Routes.project.go(project)
(or both).
I've pushed a new version of RouteCore with both RouteCore.go(url)
and Routes.project.go(project)
.
Thanks for the quick update!
However the cleanest syntax still doesn't work for me. RouteCore.context().redirect(Routes.project(project)); //works RouteCore.go("projects/" + project); // works Routes.project.go(project); // routes to http://localhost:3000/projects
Do I need to change the way the route is defined? Since RouteCore.go("projects/" + project); works I think it shouldn't?
I'll look into it. I think I may have messed up a bit. That's what I get for not testing as much as I should have.
I unfortunately don't have my computer on me. I'll have a fix out by the end of the day. I can already see my mistake. On Apr 25, 2014 2:51 PM, "Mathieu Tozer" notifications@github.com wrote:
Thanks for the quick update!
However the cleanest syntax still doesn't work for me. RouteCore.context().redirect(Routes.project(project)); //works RouteCore.go("projects/" + project); // works Routes.project.go(project); // routes to http://localhost:3000/projects
Do I need to change the way the route is defined? Since RouteCore.go("projects/" + project); works I think it shouldn't?
Reply to this email directly or view it on GitHubhttps://github.com/mystor/meteor-routecore/issues/5#issuecomment-41426972 .
Should be fixed now. Sorry about the mess-up on my part.
Thanks for this! I'm kind of new to JS otherwise I would have fixed myself :-)
iPhone$B$+$iAw?.(B
Apr 25, 2014 5:46 PM$B!"(BMichael Layzell notifications@github.com $B$N%a%C%;!<%8(B:
Should be fixed now. Sorry about the mess-up on my part.
$B!=(B Reply to this email directly or view it on GitHub.
I have the following
Routes = {};
RouteCore.map(function() { Routes.home = this.route('/', function(ctx) { return (
});
var CreateProjectButton = React.createClass({ render: function () { return( <input type="button" className="inc" value="New Project" onClick={this.addProject} /> ); }, addProject: function() { var project = Projects.insert({name:"new proj"}); Routes.project .....???? },
});
I'm trying to route to the new project page after it has been created when the user clicks the button (I can see the project being inserted correctly). The documentation isn't clear on how to go about this with react. With iron router I would have said something like Router.go("projects", {_id: project});
Is this possible?