【发布时间】:2016-04-04 07:18:06
【问题描述】:
我有一个使用 AJAX 更新的 PartialView。使用 AJAX 更新 Div 时,HTML 元素已正确加载,但 Telerik 图表未加载。图表中的数据源没有调用 Action 方法:
.DataSource(ds => ds.Read(read => read.Action("Movies_Read", "Movies")))
最初加载 PartialView 时,未使用 AJAX,数据源正在调用操作方法,并且图表已正确加载。
根据Telerik ASP.NET PartialView AJAX,OnSuccess 事件需要有这个 Javascript 调用:
<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,但是尽管我添加了 MicrosoftAjax.js 和 MicrosoftMvcAjax.js,但 get_data() 和 get_updateTarget() 事件并不存在。我怀疑这些已被弃用。 我也尝试过其他 javascript 函数,但没有任何运气。
我的 AJAX 调用是:
@using (Ajax.BeginForm("UpdateMoviesChart", "Movies", new AjaxOptions { UpdateTargetId = "MoviesDiv", InsertionMode = InsertionMode.Replace, OnSuccess = "updatePlaceholder", }))
使用 AJAX 时如何正确加载 Telerik 图表?
【问题讨论】:
标签: javascript asp.net ajax asp.net-mvc telerik