Kendo ui 剑道UI手机:拉至刷新-列表未显示
动态数据未出现在列表中。数据以jsonp格式动态获取。当在Chrome开发者工具中检查时,我能够看到响应。请在下面查找代码。有人能帮我吗Kendo ui 剑道UI手机:拉至刷新-列表未显示,kendo-ui,Kendo Ui,动态数据未出现在列表中。数据以jsonp格式动态获取。当在Chrome开发者工具中检查时,我能够看到响应。请在下面查找代码。有人能帮我吗 <!DOCTYPE html> <html> <head> <title>Pull to refresh</title> <script src="../../lib/jquery.min.js"></script> <script src="../../lib/kend
<!DOCTYPE html>
<html>
<head>
<title>Pull to refresh</title>
<script src="../../lib/jquery.min.js"></script>
<script src="../../lib/kendo.mobile.min.js"></script>
<link href="../../lib/styles/kendo.mobile.all.min.css" rel="stylesheet" />
<link href="../../lib/styles/kendo.common.min.css" rel="stylesheet" />
拉动刷新
#=头衔#
函数mobileListViewPullToRefresh(){
var dataSource=new kendo.data.dataSource({
对,,
页面大小:1,
运输:{
阅读:{
url:“http://localhost/MvcMovieApp/Mobile/RestResponse“,//删除服务url
数据类型:“jsonp”//jsonp(带填充的JSON)是跨域AJAX所必需的
},
parameterMap:功能(选项){
警报(剑道.字符串化(选项));
返回{
问:“javascript”,
页面:options.page,
rpp:options.pageSize
自\u id:options.since\u id//发送到远程服务的其他参数
};
}
},
架构:{
数据:“电影”//数据源将绑定到的数据位于“结果”字段中
}
});
警报(“kendoMobileListView之前”);
$(“#拖动以刷新列表视图”).kendoMobileListView({
数据源:数据源,
PullStoreFresh:function(){alert(“dataSource”);return true},
appendOnRefresh:true,
模板:$(“#拉动以刷新模板”).text(),
永无止境:没错,
pullParameters:函数(项){
返回{
由于_id:item.id _str,
页码:1
};
}
});
}
window.kendomobileplication=new kendo.mobile.Application(document.body);
我收到的JSONP是:
({“movies”:[{“ID”:1,“Title”:“Movie 1”,“ReleaseDate”:“/Date(1355250600000)/”,“Genre”:“喜剧”,“Price”:10},{“ID”:2,“Title”:“Movie 2”,“ReleaseDate”:“/Date(1355250600000)/”,“Genre”:“Thriller”,“Price”:10}”)返回的JSONP中必须有回调函数名。我在这里看到的输出没有任何函数名。您需要更改服务器端代码。我也有这个问题-我认为这是一种预期的行为,在appendOnRefresh:true且返回的数据未更改的情况下,不会重新绘制listview。尝试更改appendOnRefresh:false以查看任何差异阅读此内容以了解更多JSONP:阅读此内容以了解更多JSONP:
<div data-role="view" data-init="mobileListViewPullToRefresh" data-title="Pull to refresh">
<header data-role="header">
<div data-role="navbar">
<span data-role="view-title"></span>
<a data-align="right" data-role="button" class="nav-button" href="#index">Index</a>
</div>
</header>
<ul id="pull-to-refresh-listview"></ul>
</div>
<script id="pull-to-refresh-template" type="text/x-kendo-template">
#= Title #
</script>
<script>
function mobileListViewPullToRefresh() {
var dataSource = new kendo.data.DataSource({
serverPaging: true,
pageSize: 1,
transport: {
read: {
url: "http://localhost/MvcMovieApp/Mobile/RestResponse", // the remove service url
dataType: "jsonp" // JSONP (JSON with padding) is required for cross-domain AJAX
},
parameterMap: function(options) {
alert(kendo.stringify(options));
return {
q: "javascript",
page: options.page,
rpp: options.pageSize
since_id: options.since_id //additional parameters sent to the remote service
};
}
},
schema: {
data: "movies" // the data which the data source will be bound to is in the "results" field
}
});
alert("Before kendoMobileListView");
$("#pull-to-refresh-listview").kendoMobileListView({
dataSource: dataSource ,
pullToRefresh: function(){ alert("dataSource"); return true },
appendOnRefresh: true,
template: $("#pull-to-refresh-template").text(),
endlessScroll: true,
pullParameters: function(item) {
return {
since_id: item.id_str,
page: 1
};
}
});
}
</script>
<script>
window.kendoMobileApplication = new kendo.mobile.Application(document.body);
</script>
</body>
</html>