yii2 프로젝트에서 패널을 사용하고 싶습니다. kartik-v에서 헬퍼를 다운로드합니다. 패널에서 버튼을 팝업 창이나 모달로 열려고하지만 문제가 있습니다. 첫 번째 패널에서만 작동하는 모달/팝업 창이 있지만 두 번째 패널, 세 번째 패널에서 버튼을 클릭 할 때 아무 것도 발생하지 않습니다. 뭐가 문제 야? yii2의 패널에서 모달을 사용할 수 없습니다
이
코드입니다 :<?php
foreach ($dataProvider->models as $myKandidat)
{
echo '<div class="col-md-4">'
. Html::panel([
'body' => '<div class="panel-body ">'
. '<div class="row">'
. '<div class="col-md-6"><center>'
. Html::img(Yii::getAlias('@web') . '/uploads/' . "{$myKandidat->foto}", ['width' => '129px', 'height' => '150px'])
. '</center></div>'
. '<div class="col-md-6">'
. '<p>' . "{$myKandidat->nama}" . '<b>--' . "{$myKandidat->noInduk}" . '</b><br />From ' . "{$myKandidat->prodi}" .'</p>'
. '<p class="JustifyFull small"><b>Motivation: </b>' . substr("{$myKandidat->motivasi}", 0, 100)
. '... <br />'
. Html::button('Testing', ['value' => Url::to('index.php?r=kandidat/view&id=' . "{$myKandidat->idKandidat}"), 'class' => 'btn btn-success', 'id' => 'modalButton'])
. '</p>'
. '</div>'
. '</div>'
. '</div>',
'footer'=> '<center>Panel Footer</center>',
'footerTitle' => true,
Html::TYPE_DEFAULT,
])
. '</div>';
}
Modal::begin([
'header' => 'Testing',
'id' => 'modal',
'size' => 'modal-lg',
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>
이것은 main.js
$(function(){
// Get the click of the button
$('#modalButton').click(function(){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});
});
입니다 그리고 이것은 내 컨트롤러 :
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
감사합니다.
처리기 버튼 클릭 이벤트를 클릭하십시오. – ThanhPV