You need to sign in to do that
Don't have an account?
hksl
confirm box on submit for lightning button does not appear
I am going through "Build a Lightning App with the Lightning Design System" project in Trailhead.
In the AccountList.cmp component there is below code that creates "Delete" button in each row in the table created in that project.
As exercise states - click on any Delete botton should dsplay dialog box. It does Not happen.
So far I was not able to find out why, please help. Many thanks
<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>
------------------ in the javascript controller AccountListControlle.js there is following code:
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!)'); --- THIS LINE DOES NOT WORK, DIALOG BOX DOES NOT SHOW UP.
}
In the AccountList.cmp component there is below code that creates "Delete" button in each row in the table created in that project.
As exercise states - click on any Delete botton should dsplay dialog box. It does Not happen.
So far I was not able to find out why, please help. Many thanks
<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>
------------------ in the javascript controller AccountListControlle.js there is following code:
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!)'); --- THIS LINE DOES NOT WORK, DIALOG BOX DOES NOT SHOW UP.
}
Yes its trailhead mistake
use below code add new attribute type="submit" in lightning button
<lightning:button label="Delete"
iconName="utility:delete"
iconPosition="left"
variant="destructive"
type="submit"
/>
if it helps you, closed your query with choosing best answer so it make proper solution for others in future
thanks [sfdcmonkey.com]
All Answers
Yes its trailhead mistake
use below code add new attribute type="submit" in lightning button
<lightning:button label="Delete"
iconName="utility:delete"
iconPosition="left"
variant="destructive"
type="submit"
/>
if it helps you, closed your query with choosing best answer so it make proper solution for others in future
thanks [sfdcmonkey.com]