Simple modal in jQuery

前端 未结 2 1711
时光取名叫无心
时光取名叫无心 2021-01-14 23:19

I am using SimpleModal in jQuery, and I have one confirm dialog. If the result is Yes, I have to call my.php into this dialog. However, I have done

2条回答
  •  [愿得一人]
    2021-01-14 23:54

    I'm not sure that the confirm function best fits your needs, but something like this should work:

    function confirm(message, callback) {
        $('#confirm').modal({
            close:false,
            position: ["20%",],
            overlayId:'confirmModalOverlay',
            containerId:'confirmModalContainer',
            onShow: function (dialog) {
                dialog.data.find('.message').append(message);
    
                // If the user clicks "yes"
                dialog.data.find('.yes').click(function () {
                    $.get("my.php", function (data) {
                        /* Sample response:
                         *   
    my title
    *
    my message
    * */ var resp = $("
    ").append(data); var title = resp.find("#title").html(), message = resp.find("#message").html(); dialog.data.find(".header span").html(title); dialog.data.find(".message").html(message); dialog.data.find(".buttons .yes").hide(); dialog.data.find(".buttons .no").html("Close"); // No need to call the callback or $.modal.close() }); }); } }); }

提交回复
热议问题