Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

data-loading-text not working

I want have have a "Loading. . ." whenever I click on the "Submit" button. In this case, how come it did not display the "Loading. . ." thingy? bootstrap 2.3.2

<input type="submit" data-loading-text="Loading..." disabled="disabled" style="" id="save" class="btn btn-primary " value="Submit" name="save">

Here's my JS:

$('#save').click(function() {
    var btn = $(this);
    btn.button('loading');
    btn.button('reset');
});

I can't find any error in console either. What did I miss?

like image 978
ZSMJ Avatar asked May 11 '15 08:05

ZSMJ


1 Answers

Try this:

$('#save').click(function() {
      var btn = $(this);
      btn.val(btn.data("loading-text")); setTimeout(function() {
          btn.val('reset');
        }, 2000);
      });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="submit" data-loading-text="Loading..." style="" id="save" class="btn btn-primary " value="Submit" name="save">
like image 84
Ahosan Karim Asik Avatar answered Oct 18 '22 06:10

Ahosan Karim Asik