jquery - unable to open view in model popup mvc 3 -



jquery - unable to open view in model popup mvc 3 -

i want render view when user clicks on "add new" button on index page. have action in controller handles create post. problem here not able load view. when click "add new" button, nil happens. can please point out missing here?

this how index view looks like:

<script type="text/javascript"> $(function () { $('#dialog').dialog({ autoopen: false, width: 400, resizable: false, title: 'add new item', modal: true, open: function (event, ui) { $(this).load('@url.action("country/create")'); }, buttons: { "close": function () { $(this).dialog("close"); } } }); $('#addnew').click(function () { alert('hello'); $('#dialog').dialog('open'); }); }); </script> <button id="addnew" type="button">add new</button> <div id="dialog" style="overflow: hidden;"> </div>

script references:

<script src="@url.content("~/scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

layout.cshtml

<!doctype html> <html> <head> <meta charset="utf-8" /> <title>@viewbag.title</title> <link href="@url.content("~/content/site.css")" rel="stylesheet" type="text/css" /> <script src="@url.content("~/scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/modernizr-1.7.min.js")" type="text/javascript"></script> </head> <body> @renderbody() </body> </html>

--solution--

i missing jquery.ui.all.css reference.

<link href="@url.content("~/content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />

try putting javascript code between

$(document).ready(function () { ... });

jquery asp.net-mvc asp.net-mvc-3

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -