3

I have a lightning component in community builder that shows a list view of Ideas. I want to link to the custom detail page/component when the title is clicked. I tried using "window.location.href = '/ideadetails';" in my js controller but for some reason that's taking me to the new idea screen (another custom lightning component).

There is another component that I use for users to submit new ideas, but even removing that component from the list view page doesn't resolve the issue.

I did read only that window.location is not supported in lightning so my question is how should I direct the user to the actual detail page?

1 Answer 1

3

You will need to use navigate lightning function to navigate to detail .

navigateToRecord : function (component, event, helper) {
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
  "recordId": "00QB0000000ybNX"
});
  navEvt.fire();
}

Also note that you can redirect to any URL with a NavigateToURL event

  ({

   navigate : function(component, event, helper) {
    //Find the text value of the component with aura:id set to "address"
    var address = '/s/detail/'+recordId;
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url": address,
      "isredirect" :false
    });
    urlEvent.fire();
  }

})
3
  • Have you tried the force:navigateToURL event? I only ask because SF's documentation states that it's only supported in Salesforce1. Don't want that to break with a future communities update. Mar 21, 2016 at 18:58
  • Yes i have used in projects working with communities builder .It will work as community builder is based on lightning component framework . Mar 21, 2016 at 19:00
  • Thanks it worked! Wish they'd update their documentation. Wasted so much time searching for this Mar 21, 2016 at 19:10

You must log in to answer this question.

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