简体   繁体   English

如何从jQuery插件中删除x按钮

[英]How to remove x button from jquery plugin

I have an application here where if you don't do anything for about 20 seconds, it will display a idle timeout plugin message stating if you want to continue or log off. 我在这里有一个应用程序,如果您在20秒钟左右不做任何事情,它将显示一条空闲超时插件消息,指出您要继续还是注销。

The problem is that it displays ax button on the top button of the corner and if the user clicks on the x button, the message goes but in the tab the timer still continues. 问题是它在角落的顶部按钮上显示了一个x轴按钮,并且如果用户单击x按钮,则消息消失了,但是在选项卡中,计时器仍然继续。

So what my question is that how can I remove the x button in the top corner of the message? 那么我的问题是,如何删除消息顶部的x按钮?

Below is the code for the application: 下面是该应用程序的代码:

<head>
<script type="text/javascript">

$(document).ready(function()

{

    $("#dialog").dialog({
    autoOpen: false,
    modal: true,
    width: 400,
    height: 200,
    closeOnEscape: false,
    draggable: false,
    resizable: false,
    buttons: {
        'Yes, Keep Working': function(){
            // Just close the dialog. We pass a reference to this
            // button during the init of the script, so it'll automatically
            // resume once clicked
            $(this).dialog('close');
        },
        'No, Logoff': function(){
            // fire whatever the configured onTimeout callback is.
            $.idleTimeout.options.onTimeout.call(this);
        }
    }
});


$.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
    idleAfter: 5, // user is considered idle after 5 minutes of no movement
    pollingInterval: 60, // a request to keepalive.php (below) will be sent to the server every minute
    onTimeout: function(){

        // redirect the user when they timeout.
        window.location = "timeout.htm";

    },
    onIdle: function(){

        // show the dialog when the user idles
        $(this).dialog("open");

    },
    onCountdown: function(counter){

        // update the counter span inside the dialog during each second of the countdown
        $("#dialog-countdown").html(counter);

    },
    onResume: function(){

        // the dialog is closed by a button in the dialog
        // no need to do anything else

    }
});

});


</script>

</head>

<body>

<div id="dialog" title="Your session is about to expire!">
    <p>You will be logged off in <span id="dialog-countdown"></span> seconds.</p>
    <p>Do you want to continue your session?</p>
</div>
</body>
</html>

Yoou can hide the X when opening the dialog. 您可以在打开对话框时隐藏X。

$("#div2").dialog({
   closeOnEscape: false,
   open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
}); 

Here is the original SO question and answer 这是原始的SO问答

Or simply put a 或者干脆放一个

<style>
     .ui-dialog-titlebar-close { display: none ; }
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM