[SalesForce] How to delay second click on call button for some seconds in dialer in open cti

implemented dialer page using visualforce, @remoteAction javascript and Jquery.
Here the requirement is like when i click on call button more than one times, it should be ignored(Here we used jquery to initiate onclick event based on button id). How can i achieve that.

<apex:page standardController="contact" standardStylesheets="false">
<apex:slds />
<apex:includeScript value="{!$Resource.jquery}"/>

 <apex:form >
   <apex:pageBlock >
   <apex:pageBlockSection columns="1">
       <apex:inputField value="{!contact.Firstname}"/>  
       <apex:inputField value="{!contact.Lastname}"/>  
       <apex:inputField value="{!contact.AccountId}"/>   
   </apex:pageBlockSection>  
   <apex:pageBlockButtons >
   <apex:commandButton styleClass="slds-button slds-button--brand slds-button--neutral " value="JQuery Button" id="button1" onclick="buttonHide();"/>   
   </apex:pageBlockButtons> 
   </apex:pageBlock>
   </apex:form>


</apex:page>

Script as below:

function buttonHide(){
alert("Alert for Button");
$(document).on('click','.button1',function(){
    document.getElementById(button1).disabled = true;
    setTimeout(function() { 
    document.getElementById(button1).disabled = true;false }, 3000);
}
}

Best Answer

Not sure if you can prevent user from clicking the button second time. But once user click the button you can disabled the button.

So it will not allow user to click that again. You can easily do this in JavaScript

$(document).on('click','.transfer_btn',function(){
    document.getElementById(recId).disabled = true;
    setTimeout(function() { document.getElementById(recId).disabled = true;false }, 3000);
Related Topic