Hi guys,
my intention is getting alert message, if checkBox in GridView has been activated. Unfortunately, I will get nothing, neither an error nor message. What’s wrong with this code. Action in Controller actually will do its job, JavaScript will do its job for $search, for $checkBox it will not do its job. Here is View:
<?php
use yii\helpers\Html;
use kartik\grid\GridView;
use kartik\alert\Alert;
use yii\web\Session;
$this->title = Yii::t('app', 'Kunde');
$this->params['breadcrumbs'][] = $this->title;
$search = "$('.search-button').click(function(){
$('.search-form').toggle(1000);
return false;
});";
$checkBox = "$(idKunde).on('click', '#cb input[type=\'checkbox\']', function(){
if($(this).is(':checked'))
krajeeDialog.alert('Implementieren Sie die Stapelmails über den entsprechenden Button.');
});";
$this->registerJs($search);
$this->registerJs($checkBox);
?>
...
?>
<div class="kunde-index">
<!-- hier wird das HTMl-Formular, welches die Mailmethode im Controller aufruft, implementiert-->
<?=
Html::beginForm(['/kunde/send'], 'post', ['name' => 'idKunde']);
?>
...
Here is defintion of checkBoxList:
...
[
'class' => '\kartik\grid\CheckboxColumn', 'checkboxOptions' => function($model) {
return ['value' => $model->id];
},
],
...
.Here is Controllercode, which obviously is not involved solving this problem:
public function actionSend() {
$session = new Session();
$checkbox = (array) Yii::$app->request->post('selection');
if (empty(($checkbox)) && (isset($_POST['button_checkBoxes']))) {
$session->addFlash("warning", "Selektieren Sie die Bewerber, für die Mails erstellt werden sollen, über die Checkboxen");
return $this->redirect(['/kunde/index']);
}
}
...