Skip to content

Use default ember transitions for internal links #31

Description

@cmitz

It would be great not to have a normal page load in "_self" when clicking on a link inside Ember. Currently, using linkify and clicking on a link that directs to a page in the same ember-app, reloads Ember on that page, but that loading time wouldn't be there if a normal transition was used.

Our current solution is always use _blank and override the click event (not my code 😒)

click(ev) {
    // Source: https://github.com/whoward/ember-twitter-clone/commit/93af68d9f504b8b8972487e6c09851d3523a3678
    const href = this.$(ev.target).attr('href');
    if (href) {
      const parser = document.createElement('a');
      parser.href = href;
      if (!(parser.hostname === window.location.hostname || parser.hostname === `www.${window.location.hostname}`)) {
        return;
      }

      ev.preventDefault();
      const router = getOwner(this).lookup('router:main');
      router.transitionTo(parser.pathname);
    }
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions