Links with and w/o {{link-to}} helper

Hi, guys! I have faced a problem with links. When I use links via link-to helper it works without reloading the whole page. It just re-renders some part of app.

But, I just added addon for the markdown support. It also generates links that looks pretty similar to link-to links. But when I click on the link it reloads the whole app.

Is it possible to impelement link-to behaviour with usual links?

Hi there,

There is no built in method to do this. You’d have to manually catch events and handle them correctly.

Is there a way you can target the links with a selector? If so, you could try ember-href-to’s approach with an initializer for events and such: https://github.com/intercom/ember-href-to/blob/master/app/instance-initializers/browser/ember-href-to.js

1 Like

Thanks, man! I have installed this addon and have created the next extension for ember-cli-showdown:

export function initialize(/* application */) {
  showdown.extension("internal-links", function() {
  return [{
    type: 'html',
    regex: '<a href=',
    replace: '<a class="ember-href-to" href='
  }];
});
}

export default {
  name: 'register-showdown-extensions',
  initialize
};

And it works like a charm.

1 Like