我有一个包含员工的表,并且此表具有删除按钮。当按下此按钮时,行删除发生而没有任何确认消息。Grails - 根据confirm()提示消息执行表行删除
所以我试图添加这样一个confirm()对话框提示符,但我无法正确控制发生什么,因为不管我做什么,行删除总是会发生。这是因为下面的代码:
.gsp页:
<td class="text-center">
<g:link controller="employee" action="deleteRecord" params="${[id: celldata.get('id')]}">
<button type="button" class="btn btn-danger" onclick="getConfirmation();">Delete</button>
/g:link>
</td>
javascript代码:
function getConfirmation() {
var retVal = confirm("Are you sure you want to delete ?");
if(retVal == true){
alert("User wants to delete!");
return true;
}
else{
alert ("User does not want to delete!");
return false;
}
}
不管我怎么添加到提示信息,该deleteRecord功能employeeController内部将始终执行。如何根据confirm()提示中的消息停止deleteRecord函数的执行?
小提琴位于here
过去和现在仍然会使用删除函数发布默认show.gsp的函数:'onclick =“return confirm('$ {message(code:'default.button.delete.confirm.message',默认:'你确定吗?')}');“ ' – Vahid