Loading state button in Bootstrap 3

JqueryHtmlTwitter Bootstrap

Jquery Problem Overview


I'm new to Bootstrap 3. Can't figure out how to activate the loading state button function. My code below is from the documents on getboostrap.com.

<button type="button" data-loading-text="Loading..." class="btn btn-primary">
  Loading state
</button>

Dropdowns works fine so I guess the problem is somewhere else?

Jquery Solutions


Solution 1 - Jquery

You need to detect the click from js side, your HTML remaining same. Note: this method is deprecated since v3.5.5 and removed in v4.

$("button").click(function() {
    var $btn = $(this);
    $btn.button('loading');
    // simulating a timeout
    setTimeout(function () {
        $btn.button('reset');
    }, 1000);
});

Also, don't forget to load jQuery and Bootstrap js (based on jQuery) file in your page.

JSFIDDLE

Official Documentation

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkanarifuglView Question on Stackoverflow
Solution 1 - JqueryIonică BizăuView Answer on Stackoverflow