开发者

jquery dialog after button click asp.net mvc 2

开发者 https://www.devze.com 2023-03-03 12:29 出处:网络
i am struggling to get my dialog working properly. The popup shows already shows up even though i have not clicked the button?

i am struggling to get my dialog working properly. The popup shows already shows up even though i have not clicked the button?

   <script src="../../Content/jquery-ui-1.8.12.custom/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="../../Content/jquery-ui-1.8.12.custom/js/jquery-ui-1.8.12.custom.min.js"
    type="text/javascript"></script>


<link href="../../Content/jquery-ui-1.8.12.custom/css/ui-lightness/jquery-ui-1.8.12.custom.css"
    rel="stylesheet" type="text/css" />


<div>
    <button id="btnTest">
        Go</button>
</div>
<div id="dialog-confirm" title="Hello">
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
        Do you want to continue?</p>
</div>
<script type="text/javascript">

    $(document).ready(function (event) {

        $("#dialog-confirm").hide()
        $("#dialog:ui-dialog").dialog("destroy");

        $('#btnTest').click(

            $(function () {
                $("#dialog:ui-dialog").dialog("destroy");
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        "Ok":
                        function () {
                            alert('ok');
                            $(this).dialo开发者_开发问答g("close");
                        }
                    ,
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });
            })

         );

    });




</script>


You have an error in your script for the btnText function.

you have:

$('#btnTest').click( $(function () {

It should be:

$('#btnTest').click( function () {

here is a a jsFiddle with it working http://jsfiddle.net/VyGuD/3/

0

精彩评论

暂无评论...
验证码 换一张
取 消