Jquery简易确认对话框



有人知道当我点击单选按钮时如何使确认对话框出现吗?
从http://projectshadowlight.org/jquery-easy-confirm-dialog/下载代码。只是有点困惑,调整它。

下面的代码将触发确认对话框之前,单选按钮被点击!如果我使用默认的Windows对话框,它工作得很好(点击无线电然后弹出)?请提供任何解决方案!

**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 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/

我已经做了一个插件,满足您的需求。甚至更多。
我见过开发者面临的问题,这个插件解决了所有的问题,
支持:Ajax内容加载,以内容更改为中心的动态屏幕,自动关闭对话框(计时运行),功能强大。
很容易使用

 $.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/

最新更新