I am facing an issue with a PartialView that I update using AJAX. The HTML elements load correctly when updating the Div with AJAX, but the Telerik chart is not loading. The datasource in the chart does not call the Action method:
.DataSource(ds => ds.Read(read => read.Action("Movies_Read", "Movies")))
When the PartialView is initially loaded without AJAX, the datasource calls the action method and the chart loads correctly.
As per the guidance from Telerik ASP.NET PartialView AJAX, there needs to be a JavaScript call for the OnSuccess event:
<script type="text/javascript">
function updatePlaceholder(context) {
// the HTML output of the partial view
var html = context.get_data();
// the DOM element representing the placeholder
var placeholder = context.get_updateTarget();
// use jQuery to update the placeholder. It will execute any JavaScript statements
$(placeholder).html(html);
// return false to prevent the automatic update of the placeholder
return false;
}
I have tried implementing the provided JavaScript, but the get_data() and get_updateTarget() functions do not exist even though I have included MicrosoftAjax.js and MicrosoftMvcAjax.js. These may be deprecated. I have also attempted other JavaScript functions without success.
My AJAX call is as follows:
@using (Ajax.BeginForm("UpdateMoviesChart", "Movies", new AjaxOptions { UpdateTargetId = "MoviesDiv", InsertionMode = InsertionMode.Replace, OnSuccess = "updatePlaceholder", }))
How can I ensure that the Telerik Chart loads correctly when using AJAX?