简体   繁体   中英

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.

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");
}  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM