Question

I have a multipage site with multiple popups on each page. Some times there are chains of popups. E.g do you want this to happen? -> no -> reschedule -> confirm. This means that sometimes the submit actions are blocked and another popup appears. Other times just the form on the popup is submitted.

I would like to disable all of the submit buttons once they have been clicked. I've tried adding

$("input[type='submit']").attr('disabled', 'disabled'); 

Which doesn't work. I don't have a problem disabling individual submit buttons but I have lots to manage and this seems like a fairly normal problem. Do people normally individually disable the submit buttons?

Was it helpful?

Solution

what I ended up doing was

function(evt) {
  evt.preventDefault();
  evt.stopPropagation();

  // Button disable
  var disabledClass = 'ui-state-disabled',
  button = $($(evt.target).closest('button'));
  if(button.hasClass(disabledClass)) return;
  button.attr('disabled',true).addClass(disabledClass);
}

because there where multiple buttons. I've accepted the solution above as it's the most complete (and sensible) answer to this question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top