点击删除弹出“确定删除?”

从细节提升用户体验。

点击弹出再次确认窗口,防止误点删除。

从前台提交到后台有两种操作,一种是直接表单submit提交,一种是ajax提交。

弹出确认窗口使用的是js,ajax同样使用js,这种逻辑比较简单。

本文介绍submit提交,加确认框。同样需要js。

js部分:

function del(id,mid,iscid){
	if(confirm("您确定要删除吗?")){
            //点过确定需要执行的操作,ajax可以写到这里。submit提交,这里留空。
	}
}

html部分

<a class="button border-red" href="{:url('delete',['id'=>$data.id])}" onclick="return del(1,1,1)"><span class="icon-trash-o"></span> 删除</a>

重点:a标签中加入了onclick。

You May Also Like

About the Author: 萌新

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注