Вопрос

I get the data from database randomly for my page. And I would like to add a <a> tag to link to the same page for getting another random data. However, since it does nothing if the target page is the same as the current page.

Is any better way to get the new data?

Это было полезно?

Решение

Have a look at this issue: https://github.com/EventedMind/iron-router/pull/324

Basically iron-router adds events to all your a tags. Also the corresponding bit of code: https://github.com/EventedMind/iron-router/blob/79861385df5d2b667630ec82abe4de3efa3166e3/lib/client/location.js#L48

So you need to pass a selector to IronLocation that does include the a tag that does this:

E.g you could do

IronLocation.configure({
    'linkSelector' : 'a[href][data-router="true"]'
});

I'm not sure what you're a tags look like. But you could either make all the ones you want to work by changing all the a tags you want to work with iron router, like above. Or change a specific a tag and exlcude it:

'linkSelector' : 'a:not([ironskip])'

Then use <a href=".." ironskip>..</a> for the route you dont want iron-router to handle.

So this way you can specify what a tags you want iron-router to touch and which ones you dont.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top