【问题标题】:Bootbox execute request after confirmationBootbox 确认后执行请求
【发布时间】:2012-12-08 12:03:00
【问题描述】:

我想在 Rails 中的链接上添加确认弹出窗口。由于浏览器的默认 css confirm: 方法无法更改,因此我决定使用 bootbox。 (http://bootboxjs.com/)

假设我的 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;
    }
  });
});

【问题讨论】:

    标签: javascript ruby-on-rails twitter-bootstrap


    【解决方案1】:
    $("#test").click(function(e) {
      e.preventDefault();
      bootbox.confirm("Are you sure?", function(result) {
        if (result) {
          window.open($(this).attr("href"),"_self");
      });
    });
    

    我想通了,一点都不复杂,我很惊讶没有人回答:-(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-01
      • 1970-01-01
      • 2016-01-26
      • 2012-05-19
      • 1970-01-01
      相关资源
      最近更新 更多