2

I am facing the issue with :

I am using a lookup with lightning: input. When the user clicks enter search text in this input field. New component opens up showing related search records.

Now to close search window, I have a cross button in front of the field.

The user wants that on clicking anywhere outside search result component/box. This component should get closed. Now I am unable to find any workaround of attribute keyUp which we use in ui:input. Any idea how to achieve that.

enter image description here

  • 1
    have you tried wrapping your input in a div tag with the keyup attribute? I recall lightning:input not fully supporting this, hence the wrapping in a div (or any other html tag that supports onkeyup – glls Mar 19 '18 at 12:58
  • It sounds like you actually want onblur, not onkeyup? That will tell you when they've clicked outside of the lightning:input – Aidan Mar 19 '18 at 14:40
  • Thanks for suggestions! but the issue is as you can see this is a Multi check box. So when I click on a single checkbox, onblur gets called and dropdown goes off. I want, it should not go off when clicked within this component. it should go when clicked outside only. Please suggest. – Vivek Makkar Mar 19 '18 at 17:13
1

You can add the keyup to and input field, you just have to specify UpdateOn so that the change event triggers on keyup

<ui:inputText aura:id="searchInput" 
    label="Search" 
    keyup="{!c.performSearch}" 
    updateOn="keyup" />

Source

Edit: I'm pretty sure this will work on a lightning:input as well, but I haven't tested that.

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.