2013-03-15 5 views
0

Je jquery comme ça et je suis en train de charger la vue partielle, mais il ne fonctionne pas, il montre la boîte de dialogue sans aucun contrôlepourquoi vue partielle ne se charge pas

mvcJqGrid.demo.edit = function(id) { 

      var grid = $('#Products'); 
      var myCellData = grid.jqGrid('getCell', id, 'ProductId'); 
      GetProduct(myCellData); 

      return false; 


     }; 
function GetProduct(id) 
     { 

      $("#dialog-form").load("@Url.Action("EditProduct","Admin")", 
       function (response, status, xhr) { 
        $("#dialog-form").dialog('open'); 
       }); 



     } ; 

mon action est:

[HttpPost] 
    public ActionResult EditProduct(string productId) 
{ 
     int id = 0; 
     Product product = null; 
     bool result = int.TryParse(productId,out id); 
     ProductModel productModel=new ProductModel(); 
     Session["ProductModule"] = productModel.GetProduct(id); 
     return PartialView("Product_Partial", Session["ProductModule"] as ProductModel); 
    //return RedirectToAction("Product", "Admin"); 

    } 

mon vue partielle est:

@using (Html.BeginForm("Product","Admin",method:FormMethod.Post)) 
{ 

<fieldset> 
    <legend>Product Information</legend> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.ProductTitle) 
    </div> 
    <div class="editor-field"> 
     @Html.TextBoxFor(m => m.ProductTitle) 
    </div> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.ProductTypeId) 
    </div> 
    <div> 
     <select name="ProductType"> 
      <option value="null">Select ProductType</option> 
      @foreach (var row in new Database("MyConnectionString").Query<LookUp>("select * from Lookup where LookupTypeId=(select LookupTypeId from LookupType where [email protected])", "ProductType")) 
      { 
       <option value="@row.LookupId">@row.LookupName</option> 
      } 
     </select> 
    </div> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.BrandId) 
    </div> 
    <div > 
     <select name="Brand"> 
      <option value="null">Select Brand</option> 
      @foreach (var row in new Database("MyConnectionString").Query<LookUp>("select * from Lookup where LookupTypeId=(select LookupTypeId from LookupType where [email protected])", "Brand")) 
      { 
       <option value="@row.LookupId">@row.LookupName</option> 
      } 
     </select> 
    </div> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.BasePrice) 
    </div> 
    <div class="editor-field"> 
     @Html.TextBoxFor(m => m.BasePrice) 
    </div> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.ProductSpecification) 
    </div> 
    <div class="editor-field"> 
     @Html.TextBoxFor(m => m.ProductSpecification) 
    </div> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.ProductSummary) 
    </div> 
    <div class="editor-field"> 
     @Html.TextBoxFor(m => m.ProductSummary) 
    </div> 
    <div class="editor-label"> 
     @Html.LabelFor(m => m.IsOutOfStock) 
    </div> 
    <div class="ui-icon-check"> 
     @Html.CheckBoxFor(m => m.IsOutOfStock) 
    </div> 


    <table> 
     <tr> 
      <td> 
       <input type="submit" value="Add" onclick="@Url.Action("Product", "Admin")" /> 
      </td> 
      <td> 
       <button type="submit" id="btnDelete" name="Command" value="Update" onclick="@Url.Action("Product", "Admin")" >Update</button> 
      </td> 
      <td> 
       <button type="submit" id="btnSearch" name="Command" value="Delete" onclick="@Url.Action("Product", "Admin")">Delete</button> 
      </td> 
     </tr> 

    </table> 
</fieldset> 

} 

ma page vue:

<div id="dialog-form" title="Add New Product"> 

</div> 
+0

J'installe les mises à jour ne peut donc pas vérifier, mais ... l'action que vous essayez de charger dit HttpPost au-dessus. Essayez de le changer en HttpGet. Et définissez le type de retour à PartialViewResult au lieu d'un objet ActionResult. – VictorySaber

Répondre

0

Je ne vois pas l'initialisation du plugin ici ..

je vois directement:

$("#dialog-form").dialog('open'); 

mais où vous initialisez la boîte de dialogue avec des options? Je pense que vous devriez initialiser le dialogue dans votre réponse de succès au lieu d'appeler directement la fonction «ouverte».

Regardez doc jquery ui dialog

$("#dialog-form").load("@Url.Action("EditProduct","Admin")", 
      function (response, status, xhr) { 
       $("#dialog-form").dialog(); 
      }); 

J'espère que vous aiderons à