Skip to content

Instantly share code, notes, and snippets.

@jsmithdev
Last active November 28, 2018 15:18
Show Gist options
  • Select an option

  • Save jsmithdev/53248d6475ae377bb92ae2d8fd2c6c42 to your computer and use it in GitHub Desktop.

Select an option

Save jsmithdev/53248d6475ae377bb92ae2d8fd2c6c42 to your computer and use it in GitHub Desktop.
Lightning Component: Search on enter
<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
({ // 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