使用Twitter Bootstrap在模态对话框中显示进度条

时间:2015-04-14 18:44:05

标签: javascript jquery twitter-bootstrap

如何使用twitter bootstrap在模态窗口中显示进度条? 屏幕灰显但模态对话框未显示。

的jsfiddle

http://jsfiddle.net/jkittell/L0ccmgf2/4/

HTML

<body>
     <h1>Hello World!</h1>

    <div class="modal hide" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false">
        <div class="modal-header">
             <h1>Processing...</h1>

        </div>
        <div class="modal-body">
            <div class="progress progress-striped active">
                <div class="bar" style="width: 100%;"></div>
            </div>
        </div>
    </div>
</body>

的JavaScript

$(function () {
    var pleaseWait = $('#pleaseWaitDialog');

    showPleaseWait = function () {
        pleaseWait.modal('show');
    };

    hidePleaseWait = function () {
        pleaseWait.modal('hide');
    };

    showPleaseWait();
});

2 个答案:

答案 0 :(得分:9)

请改用此标记:

<!-- Modal -->
<div class="modal fade" id="pleaseWaitDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
          <h1>Processing...</h1>
      </div>
      <div class="modal-body">
        <div class="progress">
          <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
            <span class="sr-only">40% Complete (success)</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

请参阅this updated fiddle

答案 1 :(得分:8)

bootstrap-waitingfor库上使用我的扩展程序,此扩展程序包括:

  • 消息功能
  • 动画功能
  • stopAnimate function
  • 进度功能

有关更多文档,请查看此link

要获得最佳做法,请检查此FIDDLE

  waitingDialog.show('In progress ...');
  waitingDialog.progress(0);
 //----i.e: after 2 sec
 waitingDialog.progress(10); // means 10 %
 // i.e: after 2sec again 
 waitingDialog.progress(60); // means 60%

如果你想要LTR:

waitingDialog.show('Please wait',{rtl:false})