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

1
  • Try removing the () var whichOne = event.getSource.getLocalId Commented Jul 19, 2017 at 8:15

1 Answer 1

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..."/>
1
  • please close your question Commented Mar 24, 2021 at 13:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.