Skip to main content
added 1 character in body
Source Link
Rohit
  • 2.2k
  • 2
  • 13
  • 21

Just to extend the idea of @Krishna Bidwai , If you need to call c.calculateOpptyValue from c.savefunction for only one button, below approach can be used :

On your button add a div with an attribute such as

<div onclick="{!c.savefunction }" data-value="abc">
    <lightning:button label="Savelabel="Save" iconPosition="left" value="123"/>
</div>

in your controller function :

   savefunction  : function(component, event, helper) {
        var currentEvt = event.currentTarget;
        var data_Value = currentEvt.dataset.value;
        console.log(data_Value);
    if(data_Value == 'abc'){
    calculateOpptyValue();
    }
}

For more information on above technique , refer below answer from @Caspar Harmer: What is the correct way to pass Parameters to Lightning JS controller from UI:Button?

Just to extend the idea of @Krishna Bidwai , If you need to call c.calculateOpptyValue from c.savefunction for only one button, below approach can be used :

On your button add a div with an attribute such as

<div onclick="{!c.savefunction }" data-value="abc">
    <lightning:button label="Save iconPosition="left" value="123"/>
</div>

in your controller function :

   savefunction  : function(component, event, helper) {
        var currentEvt = event.currentTarget;
        var data_Value = currentEvt.dataset.value;
        console.log(data_Value);
    if(data_Value == 'abc'){
    calculateOpptyValue();
    }
}

For more information on above technique , refer below answer from @Caspar Harmer: What is the correct way to pass Parameters to Lightning JS controller from UI:Button?

Just to extend the idea of @Krishna Bidwai , If you need to call c.calculateOpptyValue from c.savefunction for only one button, below approach can be used :

On your button add a div with an attribute such as

<div onclick="{!c.savefunction }" data-value="abc">
    <lightning:button label="Save" iconPosition="left" value="123"/>
</div>

in your controller function :

   savefunction  : function(component, event, helper) {
        var currentEvt = event.currentTarget;
        var data_Value = currentEvt.dataset.value;
        console.log(data_Value);
    if(data_Value == 'abc'){
    calculateOpptyValue();
    }
}

For more information on above technique , refer below answer from @Caspar Harmer: What is the correct way to pass Parameters to Lightning JS controller from UI:Button?

Source Link
Rohit
  • 2.2k
  • 2
  • 13
  • 21

Just to extend the idea of @Krishna Bidwai , If you need to call c.calculateOpptyValue from c.savefunction for only one button, below approach can be used :

On your button add a div with an attribute such as

<div onclick="{!c.savefunction }" data-value="abc">
    <lightning:button label="Save iconPosition="left" value="123"/>
</div>

in your controller function :

   savefunction  : function(component, event, helper) {
        var currentEvt = event.currentTarget;
        var data_Value = currentEvt.dataset.value;
        console.log(data_Value);
    if(data_Value == 'abc'){
    calculateOpptyValue();
    }
}

For more information on above technique , refer below answer from @Caspar Harmer: What is the correct way to pass Parameters to Lightning JS controller from UI:Button?