<!doctype html><htmllang="en"><head><metacharset="utf-8"><title>
Ladda for Bootstrap 3 UI
</title><metaname="description"content="Bootstrap 3 loading state for buttons"><metaname="author"content="Maks Surguy"><metaname="apple-mobile-web-app-capable"content="yes"/><metaname="apple-mobile-web-app-status-bar-style"content="black-translucent"/><metaname="viewport"content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><linkrel="stylesheet"href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"><linkrel="stylesheet"href="css/ladda-themeless.min.css"></head><body><divclass="container"><divclass="row"><divclass="col-md-6 col-md-offset-3"><h1>
Ladda UI for Bootstrap 3
</h1><p>
A UI concept by
<ahref="http://twitter.com/hakimel"target="_blank">
@hakimel
</a>
which merges loading indicators into the action that invoked them. Primarily
intended for use with forms where it gives users immediate feedback upon
submit rather than leaving them wondering while the browser does its thing.
This project is used by @hakimel
<ahref="http://slid.es">
slid.es
</a>
and by @msurguy on the new upcoming
<ahref="http://bootsnipp.com"target="_blank">
Bootsnipp
</a>
.
</p><h2>
Demo
<small>
Click the buttons to see the effect
</small></h2></div></div><divclass="row"><divclass="col-md-6 col-md-offset-3 text-center"><p><buttonclass="btn btn-primary ladda-button"data-style="expand-left"><spanclass="ladda-label">
expand-left
</span></button><buttonclass="btn btn-primary ladda-button"data-style="expand-right"><spanclass="ladda-label">
expand-right
</span></button><buttonclass="btn btn-primary ladda-button"data-style="expand-up"><spanclass="ladda-label">
expand-up
</span></button><buttonclass="btn btn-primary ladda-button"data-style="expand-down"><spanclass="ladda-label">
expand-down
</span></button></p></div></div><divclass="row"><divclass="col-md-6 col-md-offset-3 text-center"><p><buttonclass="btn btn-info ladda-button"data-style="zoom-in"><spanclass="ladda-label">
zoom-in
</span></button><buttonclass="btn btn-info ladda-button"data-style="zoom-out"><spanclass="ladda-label">
zoom-out
</span></button></p></div></div><divclass="row"><divclass="col-md-6 col-md-offset-3 text-center"><p><buttonclass="btn btn-warning ladda-button"data-style="slide-left"><spanclass="ladda-label">
slide-left
</span></button><buttonclass="btn btn-warning ladda-button"data-style="slide-right"><spanclass="ladda-label">
slide-right
</span></button><buttonclass="btn btn-warning ladda-button"data-style="slide-up"><spanclass="ladda-label">
slide-up
</span></button><buttonclass="btn btn-warning ladda-button"data-style="slide-down"><spanclass="ladda-label">
slide-down
</span></button></p><p><buttonclass="btn btn-warning ladda-button"data-style="contract"><spanclass="ladda-label">
contract
</span></button></p></div></div><divclass="row"><divclass="col-md-6 col-md-offset-3 text-center progress-demo"><p>
Built-in progress bar
</p><p><buttonclass="btn btn-danger ladda-button"data-style="expand-right"><spanclass="ladda-label">
expand-right
</span></button><buttonclass="btn btn-danger ladda-button"data-style="expand-left"><spanclass="ladda-label">
expand-left
</span></button><buttonclass="btn btn-danger ladda-button"data-style="contract"><spanclass="ladda-label">
contract
</span></button></p></div></div><divclass="row"><divclass="col-md-6 col-md-offset-3 text-center"><p>
Sizes
</p><p><buttonclass="btn btn-primary btn-xs ladda-button"data-style="expand-right"data-size="xs"><spanclass="ladda-label">
extra small
</span></button><buttonclass="btn btn-primary btn-sm ladda-button"data-style="expand-right"data-size="s"><spanclass="ladda-label">
small
</span></button><buttonclass="btn btn-primary btn-lg ladda-button"data-style="expand-right"data-size="l"><spanclass="ladda-label">
large
</span></button></p></div></div><divclass="row"><divclass="col-md-6 col-md-offset-3"><h2>
Usage:
</h2><hr><p>
Include the CSS and Javascript for Spin.js and Ladda effect:
</p><pre><codeclass="language-markup"><link rel="stylesheet" href="dist/ladda-themeless.min.css"><script
src="dist/spin.min.js"></script><script src="dist/ladda.min.js"></script></code></pre><p>
Then to produce a button with the Ladda effect:
</p><pre><codeclass="language-markup"><button class="btn btn-primary ladda-button" data-style="expand-left"><span
class="ladda-label">expand-left</span></button></code></pre><p>
Or using "a" tag:
</p><pre><codeclass="language-markup"><a href="#" class="btn btn-primary ladda-button" data-style="expand-left"><span
class="ladda-label">expand-left</span></a></code></pre><p>
You can choose the style of the effect by setting the
<code>
data-style
</code>
attribute:
</p><pre><codeclass="language-markup">
data-style="expand-left" data-style="expand-left" data-style="expand-right"
data-style="expand-up" data-style="zoom-in" data-style="zoom-out" data-style="slide-left"
data-style="slide-right" data-style="slide-up" data-style="slide-down"
data-style="contract"
</code></pre><p>
You can choose the size of the spinner by setting the
<code>
data-size
</code>
attribute:
</p><pre><codeclass="language-markup">
data-size="xs" data-size="s" data-size="l"
</code></pre><p>
You can choose the color of the spinner by setting the
<code>
data-spinner-color
</code>
attribute (HEX code):
</p><pre><codeclass="language-markup">
data-spinner-color="#FF0000"
</code></pre><h2>
Control the UI state with Javascript:
</h2><p>
To activate the effect you can bind Ladda to all buttons that submit a
form
</p><pre><codeclass="language-javascript">
Ladda.bind( 'input[type=submit]' );
</code></pre><p>
When using AJAX forms, you can use the following syntax:
</p><pre><codeclass="language-markup"><a href="#" id="form-submit" class="btn btn-primary btn-lg ladda-button"
data-style="expand-right" data-size="l"><span class="ladda-label">Submit
form</span></a></code></pre><pre><codeclass="language-javascript">
$(function() { $('#form-submit').click(function(e){ e.preventDefault();
var l = Ladda.create(this); l.start(); $.post("your-url", { data : data
}, function(response){ console.log(response); }, "json") .always(function()
{ l.stop(); }); return false; }); });
</code></pre><p>
Other methods available through Javascript
</p><pre><codeclass="language-javascript">
l.stop(); l.toggle(); l.isLoading(); l.setProgress( 0-1 );
</code></pre><p>
Love this? Tweet it!
<ahref="http://twitter.com/share"class="twitter-share-button"data-text="Ladda Bootstrap - Buttons with built-in loading indicators for Bootstrap"data-url="https://github.com/msurguy/ladda-bootstrap"data-count="small"data-related="bootsnipp"></a></p><pstyle="margin-bottom:100px;">
Original Ladda UI concept by
<ahref="http://hakim.se">
Hakim El Hattab
</a>
/
<ahref="http://twitter.com/hakimel">
@hakimel
</a>
, examples adapted to work with Bootstrap 3 by
<ahref="http://twitter.com/msurguy"target="_blank">
@msurguy
</a></p></div></div></div><scriptsrc="js/spin.min.js"></script><scriptsrc="js/ladda.min.js"></script><script>// Bind normal buttons
Ladda.bind('div:not(.progress-demo) button',{
timeout:2000});// Bind progress buttons and simulate loading progress
Ladda.bind('.progress-demo button',{
callback:function(instance){var progress =0;var interval =setInterval(function(){
progress = Math.min(progress + Math.random()*0.1,1);
instance.setProgress(progress);if(progress ===1){
instance.stop();clearInterval(interval);}},200);}});// You can control loading explicitly using the JavaScript API// as outlined below:// var l = Ladda.create( document.querySelector( 'button' ) );// l.start();// l.stop();// l.toggle();// l.isLoading();// l.setProgress( 0-1 );</script></body></html>