You need to sign in to do that
Don't have an account?
Shane Gilbert
Build the AccountList Component Project - No Delete Dialog Box When Delete Button Clicked.
Hello All,
Has anyone else ran into this issue in the Trailhead "Build the AccountList Component" Project?
The code is copied from the project but I cannot get the dialog box to appear when the delete buttons are clicked.
AccountList.cmp form:
Shane
Has anyone else ran into this issue in the Trailhead "Build the AccountList Component" Project?
The code is copied from the project but I cannot get the dialog box to appear when the delete buttons are clicked.
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
I have faced the same issue. I have added type="submit" attribute in lightning:button. It working fine for me.
Thank's that worked! Some how I over looked that.
AccountList.cmp
<!-- <form class="account-form" onsubmit="{!c.deleteAccount}"> -->
<input type="hidden" value="{!account.Name}" class="account-name" />
<lightning:button label="Delete"
iconName="utility:delete"
iconPosition="left"
variant="destructive"
onclick ="{!c.deleteAccount}"
/>
<!-- </form> -->
AccountListController.js
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 = document.getElementsByClassName('account-name')[0].value;
confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
}