jquery轻松确认对话框

时间:2011-04-24 20:21:27

标签: jquery confirmation

当我点击单选按钮时,任何人都知道如何显示确认对话框 从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"));
    }
}
}   
}

2 个答案:

答案 0 :(得分:3)

单击无线电时,可以使用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/

处的工作示例

答案 1 :(得分:0)

我已经制作了一个满足您需求的插件。甚至更多。
我见过开发人员遇到问题,这个插件解决了所有问题,
支持: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/

相关问题