Last active
November 28, 2018 15:18
-
-
Save jsmithdev/53248d6475ae377bb92ae2d8fd2c6c42 to your computer and use it in GitHub Desktop.
Lightning Component: Search on enter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global"> | |
| <lightning:card > | |
| <span onkeypress="{!c.keyCheck}"> | |
| <lightning:input aura:id="searchbox" label="" name="searchbox" | |
| placeholder="Search a thing" value="" /> | |
| </span> | |
| </lightning:card> | |
| </aura:component |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ // jshint asi: true, esversion: 6, laxcomma: true | |
| keyCheck : function(c, e, h){ | |
| if (e.which == 13){ | |
| const val = c.find('searchbox').get('v.value') | |
| console.log(`Do something with ${val}`) | |
| } | |
| else { | |
| e.stopPropagation() | |
| } | |
| } | |
| })// jshint ignore: line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment