v5警报和jquery:在localsotrage中保存警报关闭事件

ryevplcw  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(163)

我想知道如何使用jquery在localstorage中保存或存储警报关闭事件。
参考:https://getbootstrap.com/docs/5.0/components/alerts/#dismissing
示例:https://codepen.io/themes4all/pen/zywewvm
jquery代码:

(function ($) {
    "use strict";

    if ($(".alert").length) {
        $(".alert").on("close.bs.alert", function (e) {
            e.preventDefault();
            var swalWithBootstrapButtons = Swal.mixin({
                customClass: {
                    confirmButton: "btn btn-primary",
                    cancelButton: "btn btn-danger me-3",
                },
                buttonsStyling: false,
            });
            swalWithBootstrapButtons
                .fire({
                    title: "Are you sure?",
                    text: "You won't be able to revert this!",
                    icon: "warning",
                    confirmButtonText: "<i class='fas fa-check-circle me-1'></i> Yes, I am!",
                    cancelButtonText: "<i class='fas fa-times-circle me-1'></i> No, I'm Not",
                    showCancelButton: true,
                    reverseButtons: true,
                    focusConfirm: false,
                })
                .then((result) => {
                    if (result.isConfirmed) {
                        $(this).off("close.bs.alert").alert("close");
                    }
                });
            return false;
        });
    }
})(window.jQuery);

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题