AccountList.cmp form:
<form class="account-form" onsubmit="{!c.deleteAccount}">
<input type="hidden" value="{!account.Name}" class="account-name" />
<!--
Use a Lightning Base Component
To display an icon next to the label
-->
<lightning:button label="Delete"
iconName="utility:delete"
iconPosition="left"
variant="destructive"
/>
</form>
AccountListController.js
({
doInit: function(component, event, helper) {
// Fetch the account list from the Apex controller
helper.getAccountList(component);
},
deleteAccount: function(component, event, helper) {
// Prevent the form from getting submitted
event.preventDefault();
// Get the value from the field that's in the form
var accountName = event.target.getElementsByClassName('account-name')[0].value;
confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
}
})
Thanks,
Shane