I have a component where upon aura:iteration (data loaded from server onInit), other components are created (list items of an SLDS lookup). The issue I have is, the onclick on the LI does not fire when I click on any of these items. I have a breakpoint on the first line of the controller function, but it never goes there. Any ideas why is this happening?

++ Since it's a lookup , the list can change when the user enters text in the input

<aura:component >

<aura:attribute name="programName" type="String" required="true" />
<aura:attribute name="programId" type="String" required="true" />
<aura:attribute name="associatedAcademicPathways" type="Object[]" required="true" />

 <li onclick="{!c.addElementToAssociatedPathways}">
     <div id="option1" class="slds-media slds-listbox__option slds-listbox__option_entity slds-listbox__option_has-meta" role="option">
         <span class="slds-media__figure">
             <span class="slds-icon_container slds-icon-standard-account">
                 <lightning:icon size="small" iconName="standard:product" alternativeText=""/>
         <span class="slds-media__body">
             <span class="slds-listbox__option-text slds-listbox__option-text_entity">{!v.programName}</span>                             

Controller function:

addElementToAssociatedPathways : function(component, event, helper){

    var programName = component.get("v.programName");
    var programId = component.get("v.programId");

    var associatedAcademicPathways = component.get('v.associatedAcademicPathways');
    associatedAcademicPathways.push({Name: programName, Id: programId});
    component.set('v.associatedAcademicPathways', associatedAcademicPathways);
  • If this is the only code part then this is all good, no issues. – itzmukeshy7 Jun 1 '18 at 20:41
  • I thought so too. Event just doesn't fire. Can't figure out why it wont go to controller function.. – JovanIvanoski Jun 1 '18 at 20:58
  • Do you see any error in console? – Avijit Chakraborty Jun 2 '18 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.