You need to sign in to do that
Don't have an account?
Agnibha Chakrabarti 10
how to get the value from <a> tag list to controller
Hi,
I want an action that, when i will click ine of those link then my input box with that name.
im giving my codes..
Component:
controller
helper
I want an action that, when i will click ine of those link then my input box with that name.
im giving my codes..
Component:
<aura:attribute name="String" type="String[]"/> <aura:handler name="init" value="{!this}" action="{!c.init}" /> <lightning:card title="Filtered Values"> <div class="search-field"> <lightning:input aura:id="nameFilter" label="Filter names" onchange="{!c.handleNameFilterChange}" /> </div> <!-- <div class="results"> <aura:if isTrue="{!v.contacts.length > 0}"> <p class="has-results"> Showing {!v.contacts.length} contact(s): </p> <ol class="slds-list_dotted"> --> <ol> <aura:iteration items="{!v.String}" var="s"> <li> <a id="getId" onclick="{!c.handleClick}"> {!s} </a> </li> </aura:iteration> </ol></lightning:card></aura:component>
controller
({ init: function(component, event, helper) { helper.loadList(component); }, handleNameFilterChange: function (component, event, helper) { helper.loadList(component); }, })
helper
({ loadList: function(component) { var action = component.get("c.allContacts"); var nameFilterString = component.find("nameFilter").get("v.value"); action.setParams({ nameFilterString: nameFilterString }); action.setCallback(this, function(a) { component.set("v.String", a.getReturnValue()); }); $A.enqueueAction(action); } })thanks,
First of all, you have to remove id attribute from anchor tag, as we don not user static id in the iteration.
You will also need to add a custom attribute to get the value of the selected anchor tag.
You have to define an method called handleClick for capturing anchor tag value and assign into the input box.
If you found it useful please appreciate my efforts and mark it as the best answer
Thanks,
Soyab
All Answers
First of all, you have to remove id attribute from anchor tag, as we don not user static id in the iteration.
You will also need to add a custom attribute to get the value of the selected anchor tag.
You have to define an method called handleClick for capturing anchor tag value and assign into the input box.
If you found it useful please appreciate my efforts and mark it as the best answer
Thanks,
Soyab
can you check?
Sorry, I forgot to add code in component,
please add this attribute in you anchor tab like this. data-item="{!s}"