提交按钮确认删除不工作在rails 3
问题描述:
我还是新来的铁轨和试图理解东西时删除多个项目。当我点击提交时,它可以工作,我可以删除多个项目,但是,无论我的确认响应如何,它都会删除。提交按钮确认删除不工作在rails 3
我使用JavaScript来检测我的提交按钮的onclick事件,我的代码是:
$('.delete').on('click', function(){
checked = countChecked();
if (checked > 1) {
confirm('Are you sure you want to delete these ' + checked + ' entries?');
} else {
confirm('Are you sure you want to delete this entry?');
};
});
我的提交按钮是:
<%= submit_tag "Delete Selected", { :class => 'delete'} %>
为什么确认没有做正确的事?它删除,即使我按取消...
答
试试这个
$('.delete').on('click', function(){
checked = countChecked();
if (checked > 1) {
return confirm('Are you sure you want to delete these ' + checked + ' entries?');
} else {
return confirm('Are you sure you want to delete this entry?');
};
});
的确认()如果按OK和False如果按取消返回True。您对通过确认返回的值无效。 – 2013-03-06 07:58:36