asp.net mvc 3 - Loading a partial view in jquery.dialog -


i new mvc , trying create dummy application learn mvc 3. have worked way through music store example , trying extend more real world application. example whenever want new item redirected create view fine want instead of doing full page post want use jquery.dialog open modal popup allow user insert new item.

so far have

  <script type="text/javascript">      $(function () {          $('#dialog').dialog({             autoopen: false,             width: 400,             resizable: false,             title: "hi there",             modal: true,             buttons: {                 "close": function () {                     $(this).dialog("close");                 }             }         });         $('#my-button').click(function () {         $('#dialog').dialog('open');         });}); </script>       <div id="dialog" title="create album" style="overflow: hidden;">     @html.partial("_createalbumpartial")</div> 

problems partial view loaded everytime not through ajax , dont know should placing partial view. shoukld in shared location or in folder other views? how update controller class cater partial view?

sorry if these easy do, im 3 days mvc :)

try this:

<script type="text/javascript">     $(function () {         $('#dialog').dialog({             autoopen: false,             width: 400,             resizable: false,             title: 'hi there',             modal: true,             open: function(event, ui) {                 //load createalbumpartial action return                  // partial view _createalbumpartial                 $(this).load("@url.action("createalbumpartial")");             },             buttons: {                 "close": function () {                     $(this).dialog("close");                 }             }         });          $('#my-button').click(function () {             $('#dialog').dialog('open');         });     }); </script> <div id="dialog" title="create album" style="overflow: hidden;"> 

we used open function triggered when dialog opened , inside send ajax request controller action return partial:

public actionresult createalbumpartial() {     return view("_createalbumpartial"); } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -