Javascript 确认后启动盒执行请求

Javascript 确认后启动盒执行请求,javascript,ruby-on-rails,twitter-bootstrap,Javascript,Ruby On Rails,Twitter Bootstrap,我想在rails中的链接上添加一个确认弹出窗口。由于浏览器的默认css confirm:method无法更改,我决定使用bootbox。() 假设我在rails应用程序中有以下链接 = link_to "asd", root_path(), id: "test" 下面的javascript代码打开一个弹出窗口,结果设置正确,如果用户批准了确认,我现在需要执行链接访问 $("#test").click(function(e) { e.preventDefault(); bootbox.c

我想在rails中的链接上添加一个确认弹出窗口。由于浏览器的默认css confirm:method无法更改,我决定使用bootbox。()

假设我在rails应用程序中有以下链接

= link_to "asd", root_path(), id: "test"
下面的javascript代码打开一个弹出窗口,结果设置正确,如果用户批准了确认,我现在需要执行链接访问

$("#test").click(function(e) {
  e.preventDefault();
  bootbox.confirm("Are you sure?", function(result) {
    if (result) {
        // ???
    } else {
        return false;
    }
  });
});
我想出来了,一点也不复杂,我很惊讶没有人回答:-(

$("#test").click(function(e) {
  e.preventDefault();
  bootbox.confirm("Are you sure?", function(result) {
    if (result) {
      window.open($(this).attr("href"),"_self");
  });
});