我已在我的应用程序中确认删除邮件,它适用于IE8-9但不适用于'IE11'和'Chrome'。我检查了所有设置,并在两个浏览器上启用了脚本。
当我点击“删除”链接时,没有任何反应只是刷新页面并且不会显示任何消息并且不会删除记录。
这是'views'目录中的_delete_from_page.rhtml文件。
btnQuestion = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 25)];
[btnQuestion setBackgroundImage:[UIImage imageNamed:@"question-mark2x"] forState:UIControlStateNormal];
[btnQuestion addTarget:self action:@selector(goBacktomain)
forControlEvents:UIControlEventTouchUpInside];
barBtnBack =[[UIBarButtonItem alloc] initWithCustomView:btnQuestion];
[self.navigationItem setLeftBarButtonItem:barBtnBack];
我从控制器'testing_page_chain_controller.rb'中调用它,如
<%= render :partial => "layouts/top_menu"%>
<%= render :active_scaffold => "testing_page_chain"%>
<html>
<head>
<script language="javascript">
function doRedirect()
{
var confirm_msg=confirm("Are you sure you want to delete the request with ID <%=@d.controller_id%>?" ,"");
var id=<%=@d.id%>
if (confirm_msg==true)
{
window.location="<%= url_for(:controller => "#{params[:controller]}")%>/confirm_delete?id="+id;
}
else
{
window.location="<%= url_for(:controller => "#{params[:controller]}")%>/cancel_delete";
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
</script>
</head>
</html>
<script language="javascript" type="text/javascript">
window.onload=addLoadEvent(doRedirect)
</script>
答案 0 :(得分:0)
为什么不使用数据确认?
<%=link_to 'Delete', url, date: {confirm: 'Are you sure?'} %>
默认情况下,这是在Rails默认安装中。然后,您可以在确认要删除对象后执行服务器内容。