0
我有一個使用AJAX更新的PartialView。使用AJAX更新Div時,HTML元素會正確加載,但Telerik圖表未加載。圖表中的數據源不調用操作方法:ASP.NET MVC AJAX部分視圖Telerik UI未加載
.DataSource(ds => ds.Read(read => read.Action("Movies_Read", "Movies")))
當PartialView最初加載,而不是使用AJAX,數據源被調用動作的方法和圖表被正確裝入。
根據Telerik ASP.NET PartialView AJAX需要有此Javascript呼籲的onSuccess事件:
<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;
}
我試圖在文件中提到的JavaScript,但GET_DATA()和get_updateTarget()不不存在的事件,雖然我havde添加了MicrosoftAjax.js和MicrosoftMvcAjax.js。我懷疑這些已被棄用。 我也嘗試了其他的JavaScript功能,但沒有任何運氣。
我的AJAX調用是:
@using (Ajax.BeginForm("UpdateMoviesChart", "Movies", new AjaxOptions { UpdateTargetId = "MoviesDiv", InsertionMode = InsertionMode.Replace, OnSuccess = "updatePlaceholder", }))
如何使用AJAX時正確加載Telerik的走勢?