0

I have a lightning component that's display search results using lightning:tile, which has an href parameter (no onclick). The component is on the account page in the service console (lightning view) and the problem is clicking the link in the tile causes the entire console to reload (bad) and then the link opens in a new primary tab (good).

Here's the code:

<lightning:tile label="{!article.UrlName}" href="{!'/lightning/r/Knowledge__kav/' + article.Id + '/view'}">
    <ul class="slds-list_horizontal slds-has-dividers_right">
        <li class="slds-item">{!article.Title}</li>
    </ul>
</lightning:tile>

Is there a way to prevent the console from reloading? Or can that not be done using tiles?

4
  • did you try using navigation events, rather than adding the navigation path in the href attribute?
    – glls
    Commented Aug 23, 2018 at 14:55
  • I'd have to wrap the tile in a dev and add an onclick to that. Looks like I'll have to use something other than tiles in order to do this correctly, thanks for the help Commented Aug 23, 2018 at 16:53
  • or, you can chose not to display a title, and add replace with a div alongside an onclick event attribute, or <a> tag with onclick
    – glls
    Commented Aug 23, 2018 at 17:06
  • i would actually recommend using lighnting:card - you can easily adapt the look and feel to match that of a tile
    – glls
    Commented Aug 23, 2018 at 17:07

1 Answer 1

1

According to the documentation, if you want to open other tabs or subtabs within the console, you should be Using Page References to Open Console Workspace Tabs and Subtabs.

Example of controller for opening a subtab:

({
    openSubtab: function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.openSubtab({
            pageReference: {
                "type": "standard__component",
                "attributes": {
                    "componentName": "c__greetings"
                },
                "state": {
                    "uid": "1",
                    "c__name": component.get("v.myName")
                }
            }
        }).then(function(tabId) {
            console.log("The new subtab ID is:" + tabId);
        }).catch(function(error) {
            console.log("error");
        });
    }
})

So, href="{!'/lightning/r/Knowledge__kav/' should be avoided

You must log in to answer this question.

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