port5432
port5432

Reputation: 6381

Changing default /submit route in Meteor

The Discover Meteor book develops a sample appliction called Microscope, with the Github repo here: https://github.com/DiscoverMeteor/Microscope

In it, the submit form seems to be defaulted (as nowhere can a see a link to /submit in the html).

<input type="submit" value="Submit" class="btn btn-primary"/>

Router.route('/submit', {name: 'postSubmit'});

How can I call this something else, eg: /postSubmit ?

Upvotes: 1

Views: 37

Answers (1)

FullStack
FullStack

Reputation: 6020

To accomplish this you could change the route path to /postSubmit

Router.route('/postSubmit', {name: 'postSubmit'});

This works because the code is using pathFor, which takes the path name provided (postSubmit) to look up the corresponding route path (/postSubmit).

For the example below the href will be substituted with /postSubmit

<a href="{{pathFor 'postSubmit'}}">Submit Post</a>

and the outcome will be:

<a href="/postSubmit">Submit Post</a>

Upvotes: 1

Related Questions