首页 > 解决方案 > 将按钮添加到 $.dialog (jquery-confirm.js)

问题描述

我目前正在使用 jquery-confirm.js 进行警报、确认和对话。

https://craftpip.github.io/jquery-confirm/

问题是我无法使按钮适应对话框,我不确定它是插件还是我对 JS 缺乏了解。

例如,我有这个对话框:

                setTimeout(function () {
              $.dialog({
                title: 'Existing user',
                content: "This account is already registered on our system. If you are the real owner, contact us!",
                icon: 'fas fa-user',
                theme: 'modern',
                animation: 'scale',
                type: 'red',
                draggable: false,
                closeIcon: function () {
                  setTimeout(function () {
                      window.location="/dashboard";
                  }, 250);
                }
              });
            }, 200);

唯一的按钮是closeIcon。如果我想把这个添加到他身上,我该怎么办?我的意思是,buttons.

                        $.confirm({
                        title: 'Confirmation',
                        content: 'Are you sure do you want to delete <strong>'+ig_name+'</strong>? We will delete all the information, however you will be able to add it again whenever you want.',
                        icon: 'fa fa-user-times',
                        animation: 'scale',
                        closeAnimation: 'scale',
                        opacity: 0.5,
                        draggable: false,
                        escapeKey: 'cancel',
                        buttons: {
                            'confirm': {
                                text: 'Delete',
                                btnClass: 'btn-blue',
                                action: function () {
                                  document.getElementById('DeleteAccountForm1').submit();
                                } 
                            },
                            cancel: {
                              text : 'Cancel',
                            },
                        }
                    });
                });

编辑:

我试过这个,但没有显示 $.dialog。

    buttons: {
    confirm: function () {
        $.alert('Confirmed!');
    },
    cancel: function () {
        $.alert('Canceled!');
    },

标签: javascriptjquerydialog

解决方案


推荐阅读