jQuery attr() not working on Bootstrap button after reset

Not sure if this is the right way, but you can use a workaround

$(document).ready(function () {
    $("#btn-id").button();

    $("#btn-id").click(function () {
        $(this).button('loading');
        setTimeout(function () {
            $("#btn-id").addClass('btn-success').data('loading-text', 'OK').button('loading')
        }, 2000);
    });
});

FIDDLE


The problem is the setTimeout used in the Button.prototype.setState() method:

https://github.com/twitter/bootstrap/blob/master/js/bootstrap-button.js#L46

Here is a workaround for this:

var $btn = $('.btn-save');
$btn.button('reset');
setTimetout(function() {
    $btn.attr('disabled', 'disabled'); // Disables the button correctly.
}, 0);

(Fiddle: http://jsfiddle.net/f0t0n/BKXVA/)


Source: https://github.com/twbs/bootstrap/issues/6242
Credit goes to: https://github.com/f0t0n