You need to sign in to do that
Don't have an account?
Yogesh Singh 03
Trailhead code error.
While going through one of the lightning tutorial on trailhead [trailhead topic you can find here "https://trailhead.salesforce.com/projects/slds-lightning-components-workshop/steps/slds-lc-4" ] I feal some code is missing in the code provided here.
In this para "Create the AccountList Component" part of code provided is.
<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>
on click of the lightning button the form should submit, and deleteAccount event should fire but its not happing. So I added "type='Submit'" property in the lightning button and then it worked. Lightning button now looks like.
<lightning:button type='Submit' label="Delete" iconName="utility:delete" iconPosition="left" variant="destructive" />.
I know this is how it works in Javascript but i am not sure about lightning. Please let me know is this the right way or am I missing something.
Thanks
In this para "Create the AccountList Component" part of code provided is.
<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>
on click of the lightning button the form should submit, and deleteAccount event should fire but its not happing. So I added "type='Submit'" property in the lightning button and then it worked. Lightning button now looks like.
<lightning:button type='Submit' label="Delete" iconName="utility:delete" iconPosition="left" variant="destructive" />.
I know this is how it works in Javascript but i am not sure about lightning. Please let me know is this the right way or am I missing something.
Thanks
You don't have to add new attribute to lightning:button.
In form tag you have onsubmit="{!c.deleteAccount}" this mean that you have to create JS controller for your component AccountListController and then create there function deleteAccount.
The JS Controller is already created but it didn't execute or called.
view sourceprint?
In the above HTML if type="Submit" is not mentioned in lightning:button, then on click of this button click event will fire and not form submit event and so deleteAccount function of JS controller will not execute or get called.
Correct me if I am wrong.
Thanks.
Please find my works sample of code and mark as best answet if this will be work for you.
AccountsController.apxc AccountList.cmp AccountListController.js AccountListHelper.js AllAccounts.app