Bootstrap - could anyone give me any example, how to set up JS buttons?

后端 未结 3 897
太阳男子
太阳男子 2021-02-05 07:24

I am playing with Bootstrap\'s stateful buttons - specifically with Loading state, but still can\'t find the right set up to get it working. I have a simple for

3条回答
  •  一向
    一向 (楼主)
    2021-02-05 07:47

    You don't need bootstrap-buttons.js. That's is HTM5, use the custom attributes. This sample does not depends of click event, it is a form submit

    var btn = $(this).find("input[type=submit]:focus");
    // loading
    var loadingText = btn.data('loadingText');
    
    if (typeof loadingText != 'undefined') {
        btn.attr("value", loadingText);
    }
    else {
        btn.attr("value", "Loading...");
    }
    btn.attr("disabled", true);
    
    $.ajax({// long task
       complete: function () {
        // reset.. the same
    });
    

提交回复
热议问题