yii2.0 模态框简单使用

时间:2022-10-20 20:41:51

<?php foreach($data as $model) :?>

  <!-- 按钮触发模态框 -->
  <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal<?=$model->id;?>">

    点击按钮显示模态框
  </button>
  <!-- 模态框(Modal) -->
  <div class="modal fade" id="myModal<?=$model->id;?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> x </button>
          <h4 class="modal-title" id="myModalLabel"> 预览 </h4>
        </div>
        <div class="modal-body">
          在这里添加一些文本
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal -->
  </div>

<?php  endforeach;?>