I have an MVC view with a number of buttons on it (each item in a basket renders 2 buttons)...
<button class="pbbg" id="ProductMinus_161637" type="button">-</button>
<button class="pbbg" id="ProductPlus_161637" type="button">+</button>
(they both have an onclick
event)
When either of these buttons are pressed I want to disable all the buttons for every product until the basket has finished updating.
The click event calls a JavaScript function which in turn makes an Ajax call. Following this post the first thing I try to do is disable all the buttons.....
$("input[type=button]").attr("disabled", "disabled");
Then after the Ajax call returns reenable them....
$("input[type=button]").removeAttr("disabled");
I am getting no errors but the buttons are not disabled.
Where I am going wrong?
inputs
(they are buttons!) - change your html to<input type="button" ... />
(and use.prop('disabled', true)
) – Ayotte