6

We have lightning community in our Salesforce org, and there are multiple custom pages created. Often we pass parameters through URL. Examples would be:

  • https://<_community-url>/s/my-orders?active=closed
  • https://<_community-url>/s/my-orders?active=current

This approach works but comes with an issue, that I believe might be bug or something overlooked when the Community Router was designed.

Normally links to subpages of Community work with routes in a way, that whole SPA is not reloaded each time you navigate. Instead, required components are fetched and subpage is rendered. This is of course much faster than loading whole SPA again. And here comes the issue. If I click link /s/my-orders everything is fine. SPA Routing works like a charm. Unfortunately when I click /s/my-orders?active=closed whole page is reloaded as if you pressed F5.

Do you know if there is a way to pass parameters when navigating to different page of community, preventing SPA reload?

1 Answer 1

3

Try force:navigateToURL event (docs).

In your component controller handle click event like this:

var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
   "url": "/my-orders?active=closed"
});
urlEvent.fire();
1
  • Apologies for accepting this answer that late. It is really a correct solution to prevent full page reload. The best way to follow that, is making a special component for all links that reside on Community and calling this event in onclick handler as well as invoking event.preventDefault() Commented Aug 9, 2018 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .