Skip to content

Instantly share code, notes, and snippets.

@pradeep-dani
Last active August 26, 2016 18:08
Show Gist options
  • Save pradeep-dani/d94df923c8c338861f077a2d4a321976 to your computer and use it in GitHub Desktop.
Save pradeep-dani/d94df923c8c338861f077a2d4a321976 to your computer and use it in GitHub Desktop.
<apex:page controller="apexController">
<script>
window.onload = function()
{
var formElement = document.querySelector("[id$='pageForm']");
if(formElement.addEventListener)
formElement.addEventListener("keypress", function(e)
{
if(e.keyCode === 13)
{
// do stuff
SearchJS();
e.preventDefault();
}
}, false);
else if(formElement.attachEvent)
formElement.attachEvent("onkeypress", function(e)
{
if(e.keyCode === 13)
{
// do stuff
SearchJS();
return e.returnValue = false;
}
});
}
</script>
<apex:form id="pageForm">
<apex:actionFunction action="{!doSearch}" name="SearchJS" reRender="resultTable, ErrorPanel" status="SearchingStatus" />
<!-- Rest of the form -->
</apex:form>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment