似乎无法扩展移动设备的视图。我想这样做是因为我可以预定义一些选项和行为。我创建了一个sample here illustrating the problem,它给出了一个错误:
Your kendo mobile application element does not contain any direct child elements with data-role="view" attribute set. Make sure that you instantiate the mobile application using the correct container.
JavaScript的:
kendo.mobile.ui.plugin(kendo.mobile.ui.View.extend({
init: function (element, options) {
kendo.mobile.ui.View.fn.init.call(this, element, options);
},
options: {
name: 'ViewCustom'
}
}));
$(function () {
new kendo.mobile.Application(document.body);
});
HTML:
<section data-role="layout" data-id="default">
<header data-role="header">
<div data-role="navbar">My App</div>
</header>
<footer data-role="footer">
<div data-role="tabstrip">
<a href="#home" data-icon="home">Home</a>
</div>
</footer>
</section>
<div id="home" data-role="viewcustom" data-layout="default">
Welcome to the home page!
</div>
http://jsfiddle.net/basememara/67RZN/
Kendo支持简单地说它不受支持 - 移动应用程序无法识别后代并且在启动时不会初始化它们。这是移动设备的一个巨大的可扩展性障碍,所以我一直在寻找源代码以查看硬编码的位置,我认为更改将位于kendo.mobile.view ViewEngine
中的某处,可能在{ {1}}。我还在kendo.mobile.pane中看到了一些硬编码视图。所以我认为这将成为使其运行的源代码的大黑客。
我的问题是有一种方法可以在不创建新类的情况下扩展视图,例如使用prototype来扩展kendo.mobile.view?任何帮助,经验或见解将不胜感激!
答案 0 :(得分:0)
而不是依赖于Kendo来查找要显示的初始视图,而不是专门搜索data-role="view"
,而是可以通过编程方式告诉它初始视图:
new kendo.mobile.Application(document.body, {
initial: "home"
});
我updated your example(并点击“主页”按钮也会导航到第二个视图,以确保其正常工作)。