yii2模态加载内容但标题模式无法看到它

时间:2016-08-01 13:52:20

标签: yii2

我无法理解为什么我不能很好地展示模态你能帮忙吗?

模态

<?php
Modal::begin([
    'header' => '<h2>Accedi</h2>',
 
    'id' => 'modalSmall',
    'size' => 'modal-sm',
    //keeps from closing modal with esc key or by clicking out of the modal.
    // user must click cancel or X to close
    'clientOptions' => ['backdrop' => 'static', 'keyboard' => true],
    'footer' => 'fdd'
]);

echo "<div id='modalContent'></div>";

Modal::end();
?>

JS

$(function() {
       $('#modalButton a').click(function(e) {
       e.preventDefault();
       $('#modalSmall').modal('show')
         .find('.modal-content')
         .load($(this).attr('href'));
      });
     });

我看到的内容

enter image description here

没有关闭按钮

1 个答案:

答案 0 :(得分:0)

<?php 

Modal::begin([
        'header' => '',
        'headerOptions' => ['id' => 'modalHeader'],
        'id' => 'modalSmall',
        'size' => 'modal-medium', //medium
         'clientOptions' => ['backdrop' => 'static', 'keyboard' => false]
      ]);

  echo "<div id='modalContent'>
        <div class='col-lg'>
          <img src='".Yii::$app->request->baseUrl."/loading.gif' width='280' height='210' alt='loading...'> // put loading.gif in backend/web/ directory
        </div>
        </di>";

Modal::end();
?>

$(function() {
       $('#modalButton').click(function(e) {
       e.preventDefault();
       $('#modalSmall').modal('show')
         .find('.modal-content')
         .load($(this).attr('value'));
document.getElementById('modalHeader').innerHTML = '<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>' + $(this).attr('title') + '</h3>';

      });
     });

如何打电话?

use yii\helpers\Url;
<p>
        <?= Html::a(Yii::t('app', 'Add Something'), null, ['class' => 'btn btn-success', 'id'=>'modalButton', 
           'value'=>Url::to(['/controller/action']),
           'title'=>'Show in Modal header'
           ]) 
        ?>
    </p>