我在提交和正确取消之前尝试进行链接确认。下面是我的代码行:
= button_to 'Complete Disconnect', {:controller => 'disconnects', :action => 'physical_disconnect', :id => d.id }, :data => { :role => 'button', :confirm => 'Are You Sure?' }
我收到对话框,但是当我点击取消时它会提交。我在这个页面上使用jquery mobile。我能做到这一点的好方法吗?
修改
所以我也尝试过:
= link_to 'Complete Disconnect', {:controller => 'disconnects', :action => 'physical_disconnect', :id => d.id }, :class => "disconnect", :onclick => "return confirm('are you sure?')", :data => { :role => "button" }
并使用此javscript:
:javascript
$('.disconnect').click(function(){
var url = this.href
if(confirm("You Sure?")){
$.ajax({
type:"POST",
url: url,
success: function(){
console.log("Success")
},
});
}
});
取消仍然提交请求