2013-05-06 67 views
1

我想在我的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> 

回答

3

你已經錯過了,實際上打開的對話框中選擇的#。在這裏看到:

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

將其更改爲:

$('#thelink') 
    .click(function() { 
     $('#dialogMsg').dialog('open'); 
    }); 
相關問題