Hello.
I’ve got a CRUD interface for one table. Deleting the item from the list view succeeds. Confirmation pops out and everything goes fine. It’s not default zii.CListView, but regular table:
<!-- views/vlan/list.php -->
echo CHtml::link('<i class="icon-remove3"></i>', '#',
array(
'submit' => Y::url("/network/vlan/del", array("id" => $vlan->id)),
'confirm' => "Are you sure you want to delete VLAN {$vlan-caption}?",
'id' => 'delete'.$vlan->id,
'class' => 'btn btn-link btn-icon btn-xs',
'title' => 'Delete',
)
);
<!-- controllers/VlanController.php -->
public function actionDel($id) {
try {
Vlan::model()->findByPk($id)->delete();
Yii::app()->user->setFlash('info', "VLAN $id successfully deleted");
} catch(Exception $e) {
Yii::app()->user->setFlash('danger', "Unable to delete VLAN $id");
$this->redirect( Y::url('/network/vlan') );
}
$this->redirect( Y::url('/network/vlan') );
}
But if I’m trying to delete the item from edit interface, i’ve got two confirmations in a row:
<!-- views/vlan/form.php -->
if( $this->action->Id == 'edit' ) {
echo CHtml::button('Delete',
array(
'submit' => Y::url("/network/vlan/del", array("id" => $model->id)),
'confirm' => "Are you sure you want to delete this VLAN?",
'id' => 'delete'.$model->id,
'class' => 'btn btn-danger',
)
);
}
echo CHtml::submitButton('Save', array('class'=>'btn btn-primary'));
I’ve found the same thing on the second CRUD module, so it’s kinda systematic.
I tried to debug the JavaScript and found, that:
-
Page is not being reloaded after the first confirmation
-
submitForm() from jquery.yii.js is being called twice. As if $(f).trigger(‘submit’) fails on a first attempt.
-
I replaced it with
$(f).submit(function(e){
alert('test');
e.preventDefault();
});
but no alert shows up. I tried to "step in" in the debugger, but sank in the depths of jQuery.
- I disabled all custom scripts. No success.
I’d appreciate any advice how to deal with this weird behavior or any kind of workaround.
Yii: 1.1.14
jQuery: 1.8.3 (framework default) or 1.10.1 (custom mapped)