moneybags
moneybags

Reputation: 1

Is there an option to turn a jQueryUI button into one that automatically disables itself when clicked?

I want to prevent someone from clicking this button twice and triggering two form submissions which could result in duplicate payments on the server:

$("#SUBMIT_PAYMENT").button(
{
    label: "SUBMIT PAYMENT",
    text: true
});

Is there an option to make a jQueryUI button automatically disable itself after it is clicked?

Upvotes: 0

Views: 58

Answers (1)

Blender
Blender

Reputation: 298512

I don't have much experience with UI, but this might work:

$("#SUBMIT_PAYMENT").button(
{
    label: "SUBMIT PAYMENT",
    text: true
}).one('click', function() {
  $(this).button('disable');
});

Upvotes: 2

Related Questions