jquery 简单确认对话框

发布于 2024-11-03 10:00:36 字数 1125 浏览 6 评论 0原文

任何人都知道如何在我单击单选按钮时出现确认对话框。
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"));
    }
}
}   
}

Anyone know how to make the confirmation dialog appear when i click on the radio buttons.
Downloaded the code from http://projectshadowlight.org/jquery-easy-confirm-dialog/. just bit confused to tweak it.

Below code will trigger the confirmation dialogue before radio button is clicked! if i use the default windows dialogue, it works fine (radio is clicked then pop up)? any solution please!

**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"));
    }
}
}   
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

装纯掩盖桑 2024-11-10 10:00:36

您可以使用 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/

You can use jQuery Ui dialog to set a confirmation when radio is clicked on. You don't need to use any plugin for this.

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
            }
        }
    });
});

Check working example at http://jsfiddle.net/jZ52e/2/

一花一树开 2024-11-10 10:00:36

我制作了一个适合您需求的插件。甚至更多。
我见过开发人员遇到问题,这个插件解决了所有问题,

支持: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/

i have made a plugin that suites your needs. and even more.
I have seen developers facing problems, and this plugin has solved all problems,

Supports: Ajax content loading, Dynamic screen centering on content change, Auto closing of dialogs (runs on timer), Powerpacked with many features.

and its easy to use !

 $.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');
     }
 });

Working example and full list of features http://craftpip.github.io/jquery-confirm/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文