t56k
t56k

Reputation: 6981

Rails: loading modal w/ twitter bootstrap

Is there a way to implement a progress/loading modal easily in Rails? I'm using Twitter Bootstrap like so:

<div class="modal hide" id="aMomentPlease" data-backdrop="static" data-keyboard="false">
  <div class="modal-header">
    <h1>A moment please</h1>
  </div>
  <div class="modal-body">
    <div class="progress progress-striped active">
      <div class="bar" style="width: 100%;"></div>
    </div>
  </div>
</div>

How do I attach it to certain actions? Like anything from sending email to image rendering. Any advice would be great.

Upvotes: 0

Views: 290

Answers (1)

jaytho
jaytho

Reputation: 100

Something Like this works:

<button type="submit" class="btn btn-primary" onclick='$("#aMomentPlease").modal("show")'>GO! 
</button>

here is a fiddle http://jsfiddle.net/jaytho/j5wJV/9/ that pops a progress modal from a search bar.

You will need to test the back button, and clear your modal. I do it this way:

window.onpopstate = function () {
    $('#aMomentPlease').modal("hide");
}  

Upvotes: 1

Related Questions