简体   繁体   English

对话框出现,然后消失

[英]Dialog Box appears and then disappears

When I click on the button Dialog Box it appears and disappears, I tired using different plugins and hundreds of tutorial but dunno why things not working properly maybe because, I am using ASP.Net page and its inheriting from a masterpage 当我点击按钮对话框时它出现并消失,我厌倦了使用不同的插件和数百个教程,但不知道为什么事情不能正常工作可能是因为,我正在使用ASP.Net页面并继承自主页

here's the code, 这是代码,

    <asp:Content ID="Content4" ContentPlaceHolderID="cphSubmit" runat="server">
<div id="question" style="display:none; cursor: default"> 
        <h1>Would you like to contine?.</h1> 
        <input type="button" id="yes" value="Yes" /> 
        <input type="button" id="no" value="No" /> 
</div> 
   <input id="test" type="submit" value="Show Dialog" /> 
    <script type="text/javascript" src="/_layouts/1033/jquery.js"></script>
    <script type="text/javascript" src="/_layouts/1033/ui.core.js"></script>
    <script type="text/javascript" src="/_layouts/1033/jquery-ui-1.7.3.custom.js

"></script>
    <script type="text/javascript" src="JS.js"></script>
    <script type="text/javascript">
         $(document).ready(function() { 

        $('#test').click(function() { 
            $.blockUI({ message: $('#question'), css: { width: '275px' } }); 
    }); 

    $('#yes').click(function() { 
        // update the block message 
        $.blockUI({ message: "<h1>Remote call in progress...</h1>" }); 

        $.ajax({ 
            url: 'wait.php', 
            cache: false, 
            complete: function() { 
                // unblock when remote call returns 
                $.unblockUI(); 
            } 
        }); 
    }); 

    $('#no').click(function() { 
        $.unblockUI(); 
        return false; 
    }); 

}); 
</script>

<hr />
</asp:Content>

Its a jquery plugin I downloaded from here, 它是我从这里下载的jquery插件,

Jquery Plugin I am using 我正在使用的Jquery插件

because you are using 因为你正在使用

<input id="test" type="submit" value="Show Dialog" />

which cause postback due to which dialog disappear try 由于哪个对话框消失而导致回发的尝试

<input id="test" type="button" value="Show Dialog" />

Try this code, I hope it will work: 试试这段代码,我希望它会起作用:

    $('#your form name').submit(function() { 
       $.blockUI({ message: $('#question'), css: { width: '275px' } });   
    }); 

your button #test is a submit button, that needs to prevent submitting to form if you want to see the message 您的按钮#test是一个提交按钮,如果您想查看该消息,则需要阻止提交到表单

try 尝试

$('#test').click(function(e) {
    e.preventDefault();
    $.blockUI({ message: $('#question'), css: { width: '275px' } }); 
});

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

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