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?

  • did you try using navigation events, rather than adding the navigation path in the href attribute? – glls Aug 23 '18 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 – Danny Singh Aug 23 '18 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 Aug 23 '18 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 Aug 23 '18 at 17:07
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.