在asp.net mvc 4中使用jqueryUI打开模式窗口VS2010

问题描述:

我想在我的asp.net mvc 4项目中点击一个链接打开一个模式窗口。我写的代码没有任何反应。我错过了什么?我在网站管理员中引用了这些链接。在asp.net mvc 4中使用jqueryUI打开模式窗口VS2010

<link type="text/css" href="@Url.Content("~/Content/custom.css")" rel="Stylesheet" /> 
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.9.1.js")" ></script> 
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.10.3.custom.min.js")"></script> 

这里是我的代码

@{ 
    ViewBag.Title = "Index"; 
    Layout = "~/Views/Shared/SiteMaster.cshtml"; 
} 


<div id="dialogMsg" title="I'm Title of dialog"> 
      Hello I'm dialog body. 
</div> 


<a href="#" id="thelink">Open Dialog</a> 



<script type="text/javascript"> 


    $(document).ready(function() { 



     $("#dialogMsg").dialog({ 
      autoOpen: false, 
      height: 300, 
      width: 350, 
      modal: true, 
      buttons: { 
       "Do something": function() { 
        var bValid = true; 

        $(this).dialog("close"); 

       }, 
       Cancel: function() { 
        $(this).dialog("close"); 
       } 
      }, 
      close: function() { 
       allFields.val("").removeClass("ui-state-error"); 
      } 
     }); 




     $('#thelink') 
     .click(function() { 
      $('dialogMsg').dialog('open'); 
     }); 
    }); 
</script> 

你已经错过了,实际上打开的对话框中选择的#。在这里看到:

$('#thelink') 
    .click(function() { 
     $('dialogMsg').dialog('open'); 
    }); 

将其更改为:

$('#thelink') 
    .click(function() { 
     $('#dialogMsg').dialog('open'); 
    });