This snippet will help to bind the enter key press to perform custom actions.
Hope this helps.
Hope this helps.
This file contains 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
<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> |
Comments
Post a Comment