0

I'm trying to create a global action that when clicked opens a new tab for google.com. The only way I have figured out how to do this is by when clicking on the global action drop down and selecting the "Go to Google" action, the modal pops up and then there is a button that when clicked send the user to Google.com in a new tab.

Instead of the 2 clicks, once on the global action, then on the button in the modal, Id like the first click on the global action to send the user to google in a new tab.

This is what I have so far:

.cmp

<aura:component implements="force:lightningQuickAction" >
     <ui:button label="Go to Google" press="{!c.openActionWindow}"/>
</aura:component>

.js

({
    openActionWindow : function(component, event, helper){
        window.open("http://www.google.com");
    }
})
0

If you want to do this without the need for a button you need your component to handle the init event:

<aura:component>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

Sample Controller:

({
    doInit: function(cmp) {
        window.open("http://www.google.com");
    }
})
0

Component:


<aura:component implements="force:lightningQuickActionWithoutHeader" >
       <aura:handler name="init" value="{!this}" action="{!c.openURL}"/>      
</aura:component>

Controller:


({
                openURL : function(component, event, helper) {

                 var urlEvent = $A.get("e.force:navigateToURL");
                 urlEvent.setParams({

                    "url": 'http://www.google.com'
                 });
                 urlEvent.fire();

                 var dismissActionPanel = $A.get("e.force:closeQuickAction");
                 dismissActionPanel.fire();
                }
})
  • Please do not just post code with no explanation as an answer. See How to Answer for how to write a good answer. – Dave Humm Dec 11 '18 at 9:27

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.