DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
224 stars 79 forks source link

LoadingText adds data element, but there is no javascript to activate it #336

Closed pennstatephil closed 9 years ago

pennstatephil commented 9 years ago

Using the LoadingText() extension on buttons successfully adds the data-loading-text element to the button, but there is no javascript in TwitterBootstrapMvcJs.js to actually change the text.

DmitryEfimenko commented 9 years ago

That script used to be in the Bootstrap.js file. They might have pulled it out for performance reasons. I'll check.

pennstatephil commented 9 years ago

it does look like there's something going on in the bootstrap.js (the button.js section) but I don't see anything about data-loading-text... you're probably right about the performance thing. If you look at the example on the site (http://getbootstrap.com/javascript/#buttons) it appears that you need additional code to initialize it now...

<button type="button" id="loading-example-btn" data-loading-text="Loading..." class="btn btn-primary">
  Loading state
</button>
<script>
  $('#loading-example-btn').click(function () {
    var btn = $(this)
    btn.button('loading')
    $.ajax(...).always(function () {
      btn.button('reset')
    });
  });
</script>

I would say it's your call whether to implement this in TBMVC js or leave it to the user to manually initialize the way the example suggests...

ETA: Actually it's even easier than all that: $('.btn').button()

DmitryEfimenko commented 9 years ago

This is in the latest JavaScript. Thanks for research!