我是 yii 的新手,遇到了一个让我很沮丧的问题。我一直在到处寻找,但没有运气。我在下面有这个gridview:
$this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'leaves-grid',
'template' => "<div>{pager}</div><div style='float:left;'>{summary}</div><div class='clear'> </div>\n{items}\n<div>{pager}</div><div style='float:left;'>{summary}</div><div class='clear'> </div><br/>",
'dataProvider'=>$model->search(),
'columns'=>array(
'id_user',
'id_leaves_type',
'leaves_from',
'leaves_to',
'leaves_desc',
'leaves_status',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'template' => '<div class="btn-group">{update}{approve}{disapprove}{cancel}</div>',
'buttons' => array(
'update' => array(
'label' => 'Edit',
'options' => array('class'=>'btn', 'rel' => ''),
'visible' => '$data->leaves_status == "Pending"'
),
'approve' => array(
'label' => 'Approve',
'icon' => 'ok',
'options' => array('class'=>'btn btn-delete', 'rel' => ''),
'click'=>'function(){return confirm("Are you sure you would like to approve this leave?");}',
'url' => 'CController::createUrl("//hrm/leaves/leaveaction", array("id"=>$data->id_leaves, "type"=>"Approved"))',
'visible' => '$data->leaves_status == "Pending"'
),
'disapprove' => array(
'label' => 'Disapprove',
'icon' => 'hand-down',
'options' => array('class'=>'btn btn-delete', 'rel' => ''),
'click'=>'function(){return confirm("Are you sure you would like to disapprove this leave?");}',
'url' => 'CController::createUrl("//hrm/leaves/leaveaction", array("id"=>$data->id_leaves, "type"=>"Not Approved"))',
'visible' => '$data->leaves_status == "Pending"'
),
'cancel' => array(
'label' => 'Cancel',
'icon' => 'remove',
'options' => array('class'=>'btn btn-delete', 'rel' => ''),
'click'=>'function(){return confirm("Are you sure you would like to cancel this leave?");}',
'url' => 'CController::createUrl("//hrm/leaves/leaveaction", array("id"=>$data->id_leaves, "type"=>"Cancelled"))',
'visible' => '$data->leaves_status == "Pending"'
),
),
'htmlOptions'=>array('style'=>'width: 150px; text-align: center;'),
),
),
));
基本上,gridview 的最右列有 4 个按钮:Edit、Approve、Disapprove 和 Cancel,并且在转到列出的 URL 之前会提示确认框。
问题是,当我单击其中一个按钮时,所有单击事件都会被触发,并且确认框都会一个接一个地出现。到底什么时候错了?请帮忙...