0

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);
}
}

1 Answer 1

0

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);
8
  • it has to ignore when i try to click more than one time with in 3 secs period.
    – ApexCode
    Mar 1, 2018 at 10:18
  • @ApexCode then you can disable it and again enable it after 3 seconds using setTimeout(function() { your_func(); }, 3000); Mar 1, 2018 at 10:25
  • i have added my code above .where i have to add setTimeout. Please tell me. I am new for these cti and jquery.
    – ApexCode
    Mar 1, 2018 at 11:03
  • @ApexCode check my updated answer. Mar 1, 2018 at 11:15
  • @ApexCode yes you need to replace it with button id Mar 1, 2018 at 13:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .