bootstrap data loading text not working

16,125

As you're using jQuery and bootstrap, you can follow this example on http://jsfiddle.net/liuyl/RdpRw/1/

$('button[data-loading-text]')
.on('click', function () {
    var btn = $(this)
    btn.button('loading')
    setTimeout(function () {
        btn.button('reset')
    }, 3000)
});

OBS: see the full sample on the link. Notice the external libraries on the left menu on jsfiddle, you can't forget to reference them.

Share:
16,125

Related videos on Youtube

Ryan Salmons
Author by

Ryan Salmons

Updated on June 04, 2022

Comments

  • Ryan Salmons
    Ryan Salmons almost 2 years

    I am trying to create a twitter bootstrap button that changes to 'Loading...' when selected until the javascript loads. However I cannot get it to work...

    Here is my html:

    <button type="submit" id="sign-up" data-loading-text="Processing..." class="btn btn-sign-up">SIGN UP</button>
    

    Javascript:

    <script>
    $('#sign-up').click(function () {
        var btn = $(this);
        btn.button('loading');
        $.ajax(...).always(function () {
        btn.button('reset');
        });
    });
    </script>
    
    • Phil
      Phil about 10 years
      Given that this is an almost exact copy of the Bootstrap example code, I'd say you're simply missing a resource (like jQuery or the Bootstrap JS file) or you've literally got $.ajax(...). What does your error console say?
    • Ryan Salmons
      Ryan Salmons about 10 years
      unexpected token which is to be expected. i am just trying to figure out what needs to be done to make this javascript element functional
    • ℛⱥℐℰşℎ
      ℛⱥℐℰşℎ about 10 years
      Try to change button type="submit" to type="button".... I think
    • Brandon Clark
      Brandon Clark over 9 years
      I don'u know if you ever solved this. If not you probly gave up by now but I am almost sure you need to add your quotes, it worked for me when it wasn't working(ie $.ajax('...').always).
    • JayhawksFan93
      JayhawksFan93 about 9 years
      Curious if you ever found a solution to this.
    • wolfyuk
      wolfyuk about 6 years
      According to the docs, this feature was deprecated in v3.3.5 and removed in v4.
    • Mavelo
      Mavelo over 5 years
      Drop-in solution for BS4 from a similar question Show Loading.. using jquery in bootstrap 4 with data-loading-text