我尝试通过模态boostrap加载ActiveForm,而是形成模态加载整页图片中的 示例
布局:main.php
...
yii\bootstrap\Modal::begin([
'header' => '<span id="modalHeaderTitle"></span>',
'headerOptions' => ['id' => 'modalHeader'],
'id' => 'modal',
'size' => 'modal-lg',
'closeButton' =>['tag'=>'close', 'label'=> 'Zamknij'],
'clientOptions' => ['backdrop' => 1, 'keyboard' =>True]
]);
echo "<div id='modalContent'></div>";
yii\bootstrap\Modal::end();
?>
...
查看:_form.php
<div class="category-form">
Lorem Ipsum
</div>
启动模式按钮:
<?= Html::button('Nowa kategoria', ['value' => Url::to(['category/create']), 'title' => 'Nowa kategoria', 'class' => 'showModalButton btn btn-success']); ?>
modal.js
$(function(){
$(document).on('click', '.showModalButton', function(){
if ($('#modal').data('bs.modal').isShown) {
$('#modal').find('#modalContent')
.load($(this).attr('value'));
document.getElementById('modalHeaderTitle').innerHTML = '<h4>' + $(this).attr('title') + '</h4>';
} else {
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
document.getElementById('modalHeaderTitle').innerHTML = '<h4>' + $(this).attr('title') + '</h4>';
}
});
});
请帮助查找错误。