Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with RenderPartial in Telerik Modal Window using Ajax
    primarykey
    data
    text
    <p>I'm having a brain meltdown since I'm combining Telerik extension with my own jQuery mix-up in my MVC3 project.</p> <p>I want to be able to call ActionResult with Ajax like this:</p> <pre><code> function showDialog(arg) { var url = '/Home/ReserveRent/'; alert(arg); $.ajax({ type: "GET", url: url, data: { id: arg }, dataType: "html", success: function(data) { $('#RenderRent').html(data); }, error: function(data) { alert(url+' '+arg+' '+data); } }); var rentPayment = $('#RenderRent').html(); $('#ModalPay' + arg).html(rentPayment); $('#Window' + arg).data('tWindow').center().open(); } </code></pre> <p>On page load I create multiple Telerik Windows which are hidden, I want to call upon each one of them with my jQuery above. My Razor page has these two Div tags included:</p> <pre><code> &lt;div&gt; @foreach (ShowAvailability availability in Model.ShowAvailabilities) { foreach (var salesLine in availability.SalesLinesForSale) { SalesLine line = salesLine; Html.Telerik().Window() .Name("Window"+line.SalesLineID) .Title("Submit feedback") .Content(@&lt;text&gt; @using (Html.BeginForm("PayRent", "Payment", FormMethod.Post, new { id = "feedback-form" })) { &lt;p class="note"&gt;This is &lt;strong&gt;salesLine&lt;/strong&gt; @line.SalesLineID.&lt;/p&gt; &lt;div id='"ModalPay"+@line.SalesLineID'&gt; &lt;!--TODO: Here will rendered Html be copied between Divs--&gt; &lt;/div&gt; &lt;div class="form-actions"&gt; &lt;button type="submit" class="t-button t-state-default"&gt;Submit feedback!&lt;/button&gt; &lt;/div&gt; } &lt;/text&gt;) .Buttons(b =&gt; b.Close()) .Width(400) .Draggable(true) .Modal(true) .Visible(false) .Render(); } } &lt;/div&gt; &lt;div id="RenderRent" style="display: none;"&gt; &lt;!-- TODO: Render payment info--&gt; @{Html.RenderPartial("ReserveRent");} &lt;/div&gt; </code></pre> <p>As you can see within my Ajax request I will render the result within the Div tag marked as #RenderRent. I therefore want to replace that Div tag with the special Div tag within the Telerik Window, and the Window now should have the correct model-info within. My controller action is like this:</p> <pre><code> public ActionResult ReserveRent(int salesLineId) { var salesLine = _salesLineLogic.GetSalesLine(salesLineId); if (!salesLine.IsAvailable) { ViewBag.AvailableSalesLine = @"Þessi orlosfeign er því miður ekki lengur til leigu á þessu tímabili."; return RedirectToAction("Index", "Home"); } salesLine.IsAvailable = false; _salesLineLogic.SaveToDatabase(); var payment = new Payment { FK_SalesLineID = salesLineId, EditedBy = "PayRent.cshtml (GET)", EditedOn = DateTime.Now }; return PartialView(new HomeFormViewModel(payment)); } </code></pre> <p>For some reason the argument is not being received from the Ajax request, the salesLineId is always NULL. Can anyone spot what I'm doing wrong with the AjaxRequest, or if the jQuery function is not declared right?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload