Help With Setting Cookie for a JQuery UI Modal Dialog

匆匆过客 提交于 2019-12-04 21:24:00

Grab the jQuery cookie plugin and change your code like so:

$(function() {
    // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
    $( "#dialog:ui-dialog" ).dialog( "destroy" );

    if ($.cookie('showDialog') == undefined || $.cookie('showDialog') == null || $.cookie('showDialog') != 'false') {
        $( "#dialog-modal" ).dialog({
            height: 475,
            width: 550,
            position: 'top',
            modal: true,
            buttons:{ "Close": function() { $(this).dialog("close"); $.cookie('showDialog', 'false', { expires: 3650 });  } },
            draggable: false,
            resizable: false
        });
    }    
});
$( '.home_page_popup' ).dialog({ 
    autoOpen: false,
    closeText: "",
    modal: true,
    resizable: false,
    icon: "ui-icon-heart",
    classes: {
        "ui-dialog": "home_page_popup_dialog"
    },
    width: pop_up_width
});

$(".home_page_popup").on("click",".popup_close",function() {

    if ($.cookie('subscribe_popup_status') == null) {
        $.cookie('subscribe_popup_status', 'shown',{ expires: popup_duration } );
    }

    $( '.home_page_popup' ).dialog('close');

});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!