【问题标题】:jquery easy confirm dialogjquery 轻松确认对话框
【发布时间】:2011-08-11 23:53:09
【问题描述】:

任何人都知道如何在我单击单选按钮时显示确认对话框。
http://projectshadowlight.org/jquery-easy-confirm-dialog/ 下载代码。只是有点困惑调整它。

以下代码将在单击单选按钮之前触发确认对话框!如果我使用默认的窗口对话框,它工作正常(点击收音机然后弹出)?请有任何解决方案!

**HTML:**
    <input class="8" id="block_t" name="t_products" onclick="goingnow(this)" type="radio" value="Block x10 (3mins)" rel="3">Block x10 (3mins)
    <input class="9" id="block_t" name="t_products" onclick="goingnow(this)" type="radio" value="Block x10 (3mins)" rel="4">Block x10 (6mins)


**javaScript function:**
function goingnow(_this){
if ($("#going_now").attr("value") == 1) {
    $("#going_now").attr("value", 0);
} else {
    if ($(_this).is(":checked") == true) {

    var conf = $(_this).is(":checked").easyconfirm({locale: { title: 'Select Yes or No', button: ['No','Yes']}});
    if (conf){
        $("#going_now").attr("value",1);
        $("#block_mins").attr("value", $(_this).attr("rel"));
    } else {
        $("#block_mins").attr("value", $(_this).attr("rel"));
    }
}
}   
}

【问题讨论】:

  • 需要更少的阻塞尝试和更多的事件驱动

标签: jquery confirmation


【解决方案1】:

您可以使用 jQuery Ui 对话框来设置单击收音机时的确认。您不需要为此使用任何插件。

var x = "Are you sure you want to take this action";
$('#test').click(function() {
    $('<div>' + x + '</div>').dialog({
        resizable: false,
        buttons: {
            "Yes": function() {
                alert('action taken') // do something here
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close"); //close confirmation
            }
        }
    });
});

http://jsfiddle.net/jZ52e/2/查看工作示例

【讨论】:

    【解决方案2】:

    我制作了一个适合您需求的插件。甚至更多。
    我见过开发人员面临问题,这个插件解决了所有问题,
    支持:Ajax 内容加载、以内容更改为中心的动态屏幕、自动关闭对话框(按计时器运行)、具有许多功能的 Powerpacked。
    而且它易于使用!

     $.alert({
         title: 'Its easy to use',
         content: 'This is the content', // your content !
         content: 'url:form.html', // URL: prefix Loads content from the url (alternatively)
         confirm: function(){
             alert('The user clicked OK');
         }
         cancel: function(){
             alert('The user clicked cancel');
         }
     });
    

    工作示例和完整功能列表http://craftpip.github.io/jquery-confirm/

    【讨论】:

      猜你喜欢
      • 2011-05-24
      • 1970-01-01
      • 2012-09-18
      • 2012-02-18
      • 1970-01-01
      • 1970-01-01
      • 2014-02-16
      • 2011-08-10
      相关资源
      最近更新 更多