Disabled jQuery user interface button remains disabled when returning to page

I have a jQuery UI to send a button in the form when it clicked, so that both times do not double-click, and also to make it clear that it was actually correctly clicked.

Therefore, I use jQuery for this:

$('input:submit').click(function() {
    $(this).button('disable');
});

This works, but the problem is that the user presses his back button and remains disabled . What is the correct way to disable the submit button when pressed? I obviously use jQuery, so it is preferable to use jQuery.

UPDATE : Many people have suggested using $(document).ready(function() {$('input:submit').button('enable');});buttons to overcome this permanent shutdown. It turns out that this will not work if it happens before the button is initialized to $(function() {}. But if I put this button ("enable") after the button initialization code even in the section $(function() {}), then it will work as expected.

But now I understand that all this button is disabled only in Firefox! If I disable the button, the form will not send in IE and Chrome (did not check others)!

UPDATE 2 . I finally got this, but a little worried that some browsers will not be able to send things using these workarounds ... Here is my last code, I would like to hear the views of potential problems:

$(function() {
    $('input:submit').button().click(function() {
        $(this).button('disable');
        $(this).closest('form').submit();
        return false;
    });
    $('input:submit').button('enable');
});
+3
5
$(document).ready(function(){
 $("input:submit").attr("disabled", "");
})
+2

.

$(document).ready(function() {
  $('input:submit').button({ disabled: false});
});
0

, , . .

0

button API jQuery. - ?

reset , , button - . :

$('input:submit').click(function() {
    $(this).attr('disabled', 'disabled');
});
0

, () "", ( , - "" ).

Add this to your page:

$(document).ready(function(){
  $("input:submit").button("enable");
});

Note that this solution uses the jQuery UI button.enable() method, which is the reverse of the method used button.disable().

0
source

Source: https://habr.com/ru/post/1779469/


All Articles