Modal Kartik Issues


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;




    		'hAlign' => GridView::ALIGN_CENTER,

    		'vAlign' => GridView::ALIGN_MIDDLE,


    		'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() {




	            id: $(this).closest('tr').data('key')


	        function (data) {







	$('#activity-modal').on('', function (e) {



); ?>

<?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>',

]); ?>


<?php Modal::end(); ?>

and clicking there messes up but if I go to my link directly: 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([




   'size' => Select2::MEDIUM,

   'pluginOptions' => [

     'allowClear' => false



and this is my controller

public function actionModalviewallocate($id) {

        return $this->renderAjax('modalviewallocate', [

            'model' => $model