Bootstrap Modal无法正常工作

时间:2015-07-27 07:01:59

标签: yii2 bootstrap-modal

 <?php echo Html::a( Yii::t( 'app', ' {modelClass}', ['modelClass' => 'SignIn',
                    ] ), [ 'account/signin' ], [ 'class' => 'btn btn-link  fa fa-sign-in btn-primary sign','style'=>'font-size:10pt;color:#428bca;' ]
                    ); ?>
<div class="modal fade" id="signModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

以上是我的模态代码。我不能让它工作(莫代尔没有弹出)。你可以看到我的模态ID是'sign',所以我的链接ID是什么,那怎么会不起作用?

1 个答案:

答案 0 :(得分:1)

试试这个

<?php
$this->registerJs(
"$(document).on('ready', function() {
    $('.sign').click(function(e) {
        e.preventDefault();
        $('#signModal').modal('show')
        .find('.modal-content')
        .load($(this).attr('href'));
    });
});")
?>