Download boot boot text does not work

I am trying to create a twitter bootstrap button that changes to "Loading ..." when it is selected before javascript is loaded. 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>
+3
source share
2 answers

When you use jQuery and bootstrap, you can follow this example at 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 full sample link. Pay attention to external libraries in the left menu on jsfiddle, you cannot forget to link to them.

+4
source

, . script $(document).ready() , $( "# sign-up" ) , click

$(document).ready(function() {
    $('#sign-up').click(function () {
        var btn = $(this);
        btn.button('loading');
        $.ajax(...).always(function () {
            btn.button('reset');
        });
    });
});

http://jsbin.com/pamujimise/edit?html,output

0

All Articles