redress
redress

Reputation: 1439

Meteor route not responding

I have a button to trigger my route speaker

<div class='btn btn-sm' id='inspect' href="{{pathFor 'speaker'}}">inspect</div>

The client-side js to handle the triggered route

Router.route('speaker', {
    path:'/speakers/:_id',
    template: 'speaker',
    data: function(){
        return Speakers.findOne(this.params._id);
    }
});

And a simple template to render the three fields of my data

<template name='speaker'>
    <h1>single speaker info</h1>
        <li>{{first}} {{last}} @ {{date}}</li>
</template>

But when I click my inspect button to trigger the route, nothing happens. I have other routes working on my app, but I can't figure out why this one wont budge.

Upvotes: 1

Views: 64

Answers (1)

saimeunt
saimeunt

Reputation: 22696

Your button is a div styled as a bootstrap button, but it do not retains HTML anchors (links) functionality.

What you need to do is defining an anchor and style it as a button :

<a class='btn btn-sm' id='inspect' href="{{pathFor 'speaker'}}">inspect</a>

There is also a {{#linkTo}} block helper in iron:router that you can use like this :

{{#linkTo class="btn btn-sm" route="speaker"}}inspect{{/linkTo}}

Upvotes: 2

Related Questions