Guys,
I have a dynagrid and one of the columns I have a link that opens a modal. So far so good. The modal opens perfect.
But when I add data inside the modal than the modal shows and my data doesn’t show and than it disappears. So for example this is my code in the view;
dynagrid
[
'attribute'=>'id',
'hAlign' => GridView::ALIGN_CENTER,
'vAlign' => GridView::ALIGN_MIDDLE,
'format'=>'raw',
'filter' => false,
'value'=>function ($model, $key, $index, $widget) {
return Html::a($key,'modalviewallocate?id='.$key.'', [
'class' => 'activity-view-link',
'data-toggle' => 'modal',
'data-target' => '#activity-modal',
'data-id' => $key,
'data-pjax' => '1',
]);
},
],
This is the code in my view:
<?php $this->registerJs(
"$('.activity-view-link').click(function() {
$.get(
'modalviewallocate',
{
id: $(this).closest('tr').data('key')
},
function (data) {
$('#activity-modal').find('.modal-body').html(data);
$('#activity-modal').modal();
}
);
});
$('#activity-modal').on('hidden.bs.modal', function (e) {
$(this).find('.modal-body').html('');
})"
); ?>
<?php Modal::begin([
'id' => 'activity-modal',
'header' => '<h4 class="modal-title">Add to Manifest</h4>',
'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
]); ?>
Loading...
<?php Modal::end(); ?>
and clicking there messes up but if I go to my link directly: http://mydomain.com/web/backend/test/modalviewallocate?id=1 than it shows my data. The data that I’m trying to show is the Select2 by Kartik. This is my code in the view:
echo Select2::widget([
'attribute'=>'manifest_name',
'name'=>'manifest_name',
'data'=>$model,
'size' => Select2::MEDIUM,
'pluginOptions' => [
'allowClear' => false
],
]);
and this is my controller
public function actionModalviewallocate($id) {
return $this->renderAjax('modalviewallocate', [
'model' => $model
]);
}