例如,我想更改bootbox.alert的警报(...
'delete' => function ($url, $model, $key) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('yii', 'Delete'),
'class'=>'btn btn-primary',
'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
'data-method' => 'post',
'data-pjax' => '0',
]);
},
答案 0 :(得分:2)
只需在元素中添加一个HTML类,然后删除&#34;数据确认&#34; param并使用&#34; click&#34;事件。 这样,您可以在单击链接时执行任何操作。
'delete' => function ($url, $model, $key) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('yii', 'Delete'),
'class'=>'btn btn-primary delete-button',
'data-id' => $model->id, // For using when the button is clicked
]);
},
在你的javascript文件中:
$(".delete-button").on("click",function(e){
e.preventDefault();
var modelId = $(this).data('id');
// Run bootbox.alert() here!!
// Based on the bootbox result, you can decide to fire the initial event again:
// $(this).unbind('submit').submit()
});
希望有所帮助:)
答案 1 :(得分:0)
只需指定一个班级名称或ID:“id”=&gt;“btn-id” 然后覆盖点击事件:
$("#btn-id").on("click",function(e){
e.preventDefault();
//Somethings and return here
}));
答案 2 :(得分:0)
链接覆盖yii.js确认 - &gt; bootbox.confirm。