生成错误:TypeError:context is undefined
我需要帮助将jquery检索到的html页面加载到模态。控制台日志打印检索到的页面,但我无法将内容 of form loaded via jquery 加载到模态中。我想这个问题出现在下面的jquery代码中
$('#modal').modal({show:true}) //show:true
.find('#modalContent')
.load($(this).html(result)); //probable error
Modal::begin([
'headerOptions' => ['id' => 'modalHeader'],
'id' => 'modal',
'size' => 'modal-lg',
'clientOptions' => ['backdrop' => 'static', 'keyboard' => FALSE]
]);
//grid view
[
'attribute' =>'client_id',
'format' => 'raw',
'value' => function ($model, $key, $index) {
return Html::a($model->staff->name, ['payments/create'], ['class'=>"popupModal","data-key"=>$model->id]);
},
],
$('.popupModal').click(function(event) {
event.preventDefault();
id = $(this).attr('data-key');
//load ajax and show model
dataObj = {'job':id};
$.ajax({
url : '" . Url::toRoute(["payments/create"]). "',
type :'get',
data :dataObj,
dataType :'html',
success:function(data){
$('#modal').modal({show:true})
.find('#modalContent')
.load($(this).attr(data));
},
})
.fail (function(xhr, status, errorThrown) {
console.dir(xhr);
});
});
答案 0 :(得分:0)
试试这种方式
<?php
Modal::begin([
'header' =>'<h4>Ficha</h4>',
'id' =>'modal',
'size' =>'modal-lg',
'clientOptions' => ['backdrop' => 'static', 'keyboard' => FALSE]
]);
echo "<div id="modalContent"> </div>";
Modal::end();
?>