0

I am using Lightning button and on the click of the button I am calling a method in JS controller. I followed the below article to identify the button name but unsuccessful. The moment I start typing in value on the field it pops up the error.

Component bundle version : 40.0

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_which_button_pressed.htm

<div aura:id="lookup" class="slds-show">    
    <input class="slds-input" type="text" aria-haspopup="true" aria-autocomplete="list" role="combobox" aria-expanded="true" aria-activedescendant="" aria-owns="companyList" value="{!v.searchString}" updateOn="keyup" onkeyup="{!c.runSearch}" placeholder="Search Companies..."/>
    <p>You clicked: {!v.whichButton}</p>
    <lightning:button  aura:id="lookupbutton" class="slds-button slds-input__icon slds-text-color--default"  iconName="utility:search" variant="base" onclick="{!c.runSearch}" value="{!v.searchString}" />
</div>

Here is my JS controller:

runSearch : function(component, event, helper) {
//  if(event.keyCode == 13 || event.which == 13){ //Enter key
        var whichOne = event.getSource().getLocalId();
        console.log(whichOne);
        component.set("v.whichButton", whichOne);
        var searchString = event.target.value;
        component.set("v.searchString", searchString);
        component.set("v.SECompanies", null);
        console.log(searchString);
        helper.runSearchHelper(component);
//  }
}

enter image description here

enter image description here

  • Try removing the () var whichOne = event.getSource.getLocalId – GibiDroidZ Jul 19 '17 at 8:15
0

I realized the code updateOn, onkeyup is the culprit which is triggering when entered value in the lookup. I was able to sort it out.

<input class="slds-input" type="text" aria-haspopup="true" aria-autocomplete="list" role="combobox" aria-expanded="true" aria-activedescendant="" aria-owns="companyList" value="{!v.searchString}" updateOn="keyup" onkeyup="{!c.runSearch}" placeholder="Search Companies..."/>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.