'status' => array(
'label'=>"<i class='fa fa-eye-slash'></i>", // text label of the button
'url'=>function ($data)
{
return $this->createUrl("counters/changeStatus",array('id'=>$data->counter_id, "status"=>$data->status ? 0 : 1 ));
}, // a PHP expression for generating the URL of the button
'imageUrl'=>false, // image URL of the button. If not set or fa lse, a text link is used
'options'=>array(
'class'=>'btn roundPoint4 btn-xs green btn-warning statusBtn',
'title'=>"Activate/Deactivate",
), // HTML options for the button tag
'click'=>'function(e){
e.preventDefault();
//open confirmation box write ur code here
}', // a JS function to be invoked when the button is clicked
'visible'=>function()
{
return true;
}, // a PHP expression for determining whether the button is visible
),
现在我告诉你我做什么,在我的代码为嘛你想要做
'status' => array(
'label'=>"<i class='fa fa-eye-slash'></i>", // text label of the button
'url'=>function ($data)
{
return $this->createUrl("counters/changeStatus",array('id'=>$data->counter_id, "status"=>$data->status ? 0 : 1 ));
}, // a PHP expression for generating the URL of the button
'imageUrl'=>false, // image URL of the button. If not set or fa lse, a text link is used
'options'=>array(
'class'=>'btn roundPoint4 btn-xs green btn-warning statusBtn',
'title'=>"Activate/Deactivate",
), // HTML options for the button tag
'click'=>'function(e){
e.preventDefault();
$(this).parents("table").find("tr.workingRowClass").removeClass("workingRowClass");
$("#secretForm").html("");
var parts = getMyIdNew($(this).attr("href"), "/status/", "/id/") ;
setAction($("#secretForm"), "POST", parts[2], 1)
moslakeFormInput($("#secretForm") , "Counters[id]", "hidden", parts[1] , "id");
moslakeFormInput($("#secretForm") , "Counters[status]", "hidden", parts[0], "status");
moslakeFormInput($("#secretForm") , "operation", "hidden", "statusChange", "operation");
$("#promptAlert").find(".modal-body").html("<p>Are you sure you want to change status of the this Item ?</p>");
$("#promptAlert").modal("show"); $(this).parents("table").find("tr").removeClass("deleteMode");
$(this).parents("tr").addClass("workingRowClass");
}', // a JS function to be invoked when the button is clicked
'visible'=>function()
{
return true;
}, // a PHP expression for determining whether the button is visible
),
我有复制粘贴代码。所以它会是额外的。当有人点击“状态”按钮时。它将打开引导模式。并要求确认。执行此操作时,我创建了一个包含操作和一些字段的表单。在那种模式下,我继续按钮。点击继续按钮,表格将被提交。并关闭表格将被清空。该表单将显示无形式。并将所有的领域隐藏..我知道这是更复杂的然后urs ...但我这样做后... 但你可以分配你的HREF发布按钮链接在这个功能和单击它,它会被重新删除
Jaimin MosLake 'click'=>'function(e){e.preventDefault();警告(“hola”);}', 这是我的'点击'看起来如何..它不会执行任何JavaScript,这是这里的主要问题.. – Himanshu97
只是检查是否加载脚本.... Yii在body标签结束之前将脚本加载到脚本tage中...因此请检查您的脚本是否已加载...是否通过ajax ..或renderPartial加载了您的页面,请检查所有内容......它应该可以正常工作..只需检查是否包含在网页中的代码...然后检查其他东西 –
我renderPartial(),因为我有这个gridview作为部件 – Himanshu97