Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7858927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:40:47+00:00 2026-06-02T21:40:47+00:00

What is the best way to disable a button so a double click doesn’t

  • 0

What is the best way to disable a button so a double click doesn’t occur with knockout.js. I have some users doing some quick clicking causing multiple ajax requests. I assume knockout.js can handle this in several ways and wanted to see some of the alternatives out there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:41:05+00:00Added an answer on June 2, 2026 at 9:41 pm

    Use a semaphore (spinning lock). Basically, you count how many clicks an element has registered and if it is more than 1 you return false and don’t allow the following clicks. A timeout function could be used to clear the lock so that they could click again after say, 5 seconds. You could modify the example from http://knockoutjs.com/documentation/click-binding.html

    As seen here:

    <div>
     You've clicked <span data-bind="text: numberOfClicks"></span> times
     <button data-bind="click: incrementClickCounter">Click me</button>
    </div>
    
    <script type="text/javascript">
     var viewModel = {
         numberOfClicks : ko.observable(0),
         incrementClickCounter : function() {
             var previousCount = this.numberOfClicks();
             this.numberOfClicks(previousCount + 1);
         }
     };
    </script>
    

    By changing the logic inside the nested function to

    if( this.numberOfClicks() > 1 ){
     //TODO: Handle multiple clicks or simply return false
     // and perhaps implement a timeout which clears the lockout
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following this thread to disable/ enable the click on a button, Best
The best way of describing this is I have a table of people with
What is the best way to disable Alt + F4 in a c# win
Not sure of the best way to explain this... I have an input where
What is the best way to disable UITextField's 'return' keyboard key if input area
the best way to explain is with example so: this is the model public
The best way I can think of to ask this is by example... In
The best way to store images into MySQL is by storing the image location
What is the best way to maintain upgrade scripts between versions of a product?
What is the best way to view the HTTP response headers from a request

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.