jquery - How to update ViewModel ni PartialView then post the updated ViewModel from View? -


I do not know what my title means anyway, but let me explain what I was trying to do I am

I see a product with a ProductViewModel and a Html.BeginFrom ("AddToCart Like", "Cart") Add Product to Cart for.

Productview:

@ Model Website. VisualModels.ProductViewModel @ {HTMLRenderPartial ("_textEditor", model); } @using (Html.BeginForm ("like addToCart", "cart")) {@ Html.HiddenFor (model = & gt; model.EditorImageUrl) & lt; Input type = "number" id = "volume" name = "volume" value = "@ model.product.minimum" minimum = "1" max = "99 99" /> & Lt; Input type = "submit" value = "add to basket" / & gt; }

In the product view, I also present a partial view which takes ProductViewModel the same. (; Model.EditorHtml Model = & gt) In partial view, I like a CKEditor then is bound to @ Html.TextAreaFor my ProductViewModel.EditorHtml property. I will have to submit EditorHtml to generate an image on another server. I do this by using Ajax. Beginform GenerateImage Action Where I request to generate my image I come back with ImageUrl in ProductViewModel.EditorImageUrl set

PartialView TextEditor:.

  @model Webshop.ViewModels.ProductViewModel & Lt; Div id = "designForm" & gt; & Lt; Button type = "button" id = "model opening" class = "editorInput" & gt; & Lt; Img src = "@ Model.EditorImageUrl" alt = "TextEditor" & gt; & Lt; / Button & gt; & Lt; Div id = "dialog-text-editor" & gt; @using (Ajax.BeginForm ("GenerateImage", "Image" New AjaxOptions {UpdateTargetId = "designForm", HttpMethod = "Post", onSuccess = "closeDialogCallback"})) {& lt; Div & gt; @ Html.HiddenFor (model => Model .ProductId) @ Html.TextAreaFor (model => model.EditorHtml) & lt; / Div & gt; & Lt; Div & gt; & Lt; Button type = "submit" title = "preview" id = "btn generate preview" & gt; Preview & lt; / Button & gt; & Lt; Button type = "button" heading = "off" id = "BTN cancellation" & gt; Close & lt; / Button & gt; & Lt; / Div & gt; } & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Script & gt; $ (Document) .ready (function () {// textbook dialog $ ('# dialog-text-editor') dialog ({autoOpen: incorrect, resizable: incorrect, dragable: true, modal: true , "Text Editor", Width: 550, Height: 550,}) $ ('# EditorHtml') .ckeditor (); $ ("# modal-opener") Click (function () {$ (" (Dialogue) "$" ("open"); "$" ("# BTN cancellation") Click (function () {$ ("# dialog-text-editor") dialog ("closed" );});}); Close functionDialogClock () {$ ("# dialog-text-editor") dialog ("off" "};}  

ImageController

  [HttpPost] [valid input (wrong)] public partial view view generated image {View Productview ModelModel} {// In this method, I see the ViewModel.EditorImageUrl CreateImage Set (ViewModel); Return a Partial View ("_TextEditor", seeModel);}  

This is where I need some guidance. In partial view, with all the properties that are populated with the values ​​of my Ajax Post, I want to add my productive model to A How can I submit to the Pan Cart Controller? These values ​​are always empty.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -