Check,if checkBox is activated

Hi guys,

with help of umneeq, i extended code in order to get activated different alertBoxes. My extension fails. What is wrong with this code?

In GridView,I defined id like this




$gridColumn = [

.

.


        [

                'class' => '\kartik\grid\CheckboxColumn', 'checkboxOptions' => function($model) {

                    return ['value' => $model->id];

                },

            ],

.

.

];

<?=

        GridView::widget([

            'dataProvider' => $dataProvider,

            'filterModel' => $searchModel,

            'filterSelector' => '.choiceRadio',

            'id' => 'cb',

            'columns' => $gridColumn,



now, I try to send back alertBoxes like this, but i fail:





$checkBox = "$(document).on('click', '#cb input[type=\'checkbox\']', function(){

   			if($('#cb').is(':checked'))  

   			alert($(this).val()+'is already checked'); else

   		krajeeDialog.alert('Löschen Sie diese Datensätze durch das Bootstrap-Trash Symbol oben');  

    });";

    $this->registerJs($checkBox);



P.S.: i will get no error from JS-Debugger. Second alertBox will be shown up always, so if-condition is always false

Got it by my own. Here is code,which will do its job correctly:





    $checkBox = "$(document).on('click', '#cb input[type=\'checkbox\']', function(){

               if($(this).is(':checked'))  

               krajeeDialog.alert($(this).val()+'is checked'); else

           krajeeDialog.alert('Löschen Sie diese Datensätze durch das Bootstrap-Trash Symbol oben');  

    });";