0

I cant get my dialog to close, what am I doing wrong here? I am trying to integrate this script in my asp.net mvc 3 app?

<p id="dialog_link" style="cursor: pointer;">
    Open Dialog
</p>
<div id="Dialog" title="Dialog title!" style="display: none;">
    @*  @{Html.RenderAction("Categories");}*@
    @{Html.RenderAction("About");}
</div>
<link href="../../Content/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript">
</script>
<script type language="javascript">

    $(function () {
        var execute = function () {
            //alert('This is Ok button');
        };
        var cancel = function() {
            //alert('This is Cancel button');
            $("#Dialog").dialog('close');
        };
        var dialogOpts = {
            buttons: {
                "Ok": execute,
                "Cancel": cancel
            }
        };
        $("#Dialog").dialog(dialogOpts);
    });

</script>
4

3 回答 3

1

Try this: http://jsfiddle.net/FgRqx/

<script type="text/javascript">

    $(function () {
        $('#dialog_link').click(function(e){
            e.preventDefault();

            $("#Dialog").dialog({
                buttons:    {
                    'OK': function(){
                        console.log('OK clicked!');
                    },
                    'Close': function(){
                        $(this).dialog('close');
                    }
                }
            });
        });
    });

</script>
于 2012-08-04T09:03:43.860 回答
0

check this fiddle

http://jsfiddle.net/piyushsardana47/26hzZ/

于 2012-08-04T09:04:04.353 回答
0

Working demo http://jsfiddle.net/BWXNe/

something like this man! Hope it fits your cause!

scripts

  <script type='text/javascript' src='http://code.jquery.com/jquery-1.5.js'></script>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>

      <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/blitzer/jquery-ui.css">

code

$(document).ready(function() {
    $('#dialog_link').click(function(){
                $( "#Dialog" ).dialog( "open" );    
    });

    $( "#Dialog" ).dialog({
            modal: true,
            autoOpen: false,
            height: 255,
            width: 300,
            buttons: {
                "Retrieve": function() {

                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
    });


});


​
于 2012-08-04T09:07:38.473 回答