使用 HTTP POST 通过 Kendo 标签条加载内容
Use HTTP POST for loading content via Kendo tabstrip
Kendo tabstrip 接受内容加载 ContentUrl 作为 ajax 通过 HTTP GET,有没有办法通过 POST 加载此内容?
kendo 标签条接受 kendo.data.Datasource 用于加载内容
见http://dojo.telerik.com/EmECoy
$("#tabstrip").kendoTabStrip({
dataTextField: "Name",
dataContentUrlField: "ContentUrl",
dataSource: [
{ Name: "Tab1", ContentUrl: "http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent1.html" },
{ Name: "Tab2", ContentUrl: "http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent2.html" }
]
});
kendo.data.DataSource 有可用的 READ type of "POST" 但我不知道是否可以将此机制插入标签条的内容加载.. 或者我是否坚持使用 AJAX GET 调用来检索它?
这是我绕过加载内容的内置选项卡机制的解决方案:http://dojo.telerik.com/omOre
选项卡定义中的空内容 url:
jQuery(function(){jQuery("#tabstrip").kendoTabStrip({"select":onselect,"activate":onactivate,"contentLoad":onContentLoad,"animation":false,"contentUrls":["","","",""]});});
//Track our content
var tabcontent = [{"contentloaded":true},{"url":"http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent1.html"},{"url":"http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent2.html"},{"url":"http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent3.html"} ];
实施"select"事件
- 确定我们是否应该通过 AJAX (post) 加载选项卡
- 跟踪选项卡是否已加载
//When selected, if ajax and not not loaded - load the content
function onselect(e) {
console.log("select");
var index = $(e.item).index();
var taburl = tabcontent[index].url;
var contentloaded = tabcontent[index].contentloaded;
if(taburl !== "" && contentloaded !== true)
{
//get reference to the TabStrip widget
var ts = $("#tabstrip").data("kendoTabStrip");
//get the tab content
var item = ts.contentElement(index);
$.ajax({
type: "get",//simple change! "post",
url: taburl,
success: function (response) {
$(item).html(response);
tabcontent[index].contentloaded = true;
console.log("Tab Index: " + index + ", Url: " + taburl + " [[ajax success]]");
}
});
}
}
Kendo tabstrip 接受内容加载 ContentUrl 作为 ajax 通过 HTTP GET,有没有办法通过 POST 加载此内容?
kendo 标签条接受 kendo.data.Datasource 用于加载内容
见http://dojo.telerik.com/EmECoy
$("#tabstrip").kendoTabStrip({
dataTextField: "Name",
dataContentUrlField: "ContentUrl",
dataSource: [
{ Name: "Tab1", ContentUrl: "http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent1.html" },
{ Name: "Tab2", ContentUrl: "http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent2.html" }
]
});
kendo.data.DataSource 有可用的 READ type of "POST" 但我不知道是否可以将此机制插入标签条的内容加载.. 或者我是否坚持使用 AJAX GET 调用来检索它?
这是我绕过加载内容的内置选项卡机制的解决方案:http://dojo.telerik.com/omOre
选项卡定义中的空内容 url:
jQuery(function(){jQuery("#tabstrip").kendoTabStrip({"select":onselect,"activate":onactivate,"contentLoad":onContentLoad,"animation":false,"contentUrls":["","","",""]});});
//Track our content
var tabcontent = [{"contentloaded":true},{"url":"http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent1.html"},{"url":"http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent2.html"},{"url":"http://demos.telerik.com/kendo-ui/content/web/tabstrip/ajax/ajaxContent3.html"} ];
实施"select"事件 - 确定我们是否应该通过 AJAX (post) 加载选项卡 - 跟踪选项卡是否已加载
//When selected, if ajax and not not loaded - load the content
function onselect(e) {
console.log("select");
var index = $(e.item).index();
var taburl = tabcontent[index].url;
var contentloaded = tabcontent[index].contentloaded;
if(taburl !== "" && contentloaded !== true)
{
//get reference to the TabStrip widget
var ts = $("#tabstrip").data("kendoTabStrip");
//get the tab content
var item = ts.contentElement(index);
$.ajax({
type: "get",//simple change! "post",
url: taburl,
success: function (response) {
$(item).html(response);
tabcontent[index].contentloaded = true;
console.log("Tab Index: " + index + ", Url: " + taburl + " [[ajax success]]");
}
});
}
}