【发布时间】:2014-04-01 13:33:07
【问题描述】:
刚刚在使用 dojo mobile 时遇到了 dojo 模板问题。我想为 EdgeToEdgeStoreList 创建自定义 ListItem。
主 html 文件 index.html 包含
<div data-dojo-type="dojox.mobile.EdgeToEdgeStoreList" data-dojo-props="itemRenderer:app.widgets.CustomListItem" id="list"></div>
.js 文件在列表中设置存储:
require([ "dojo/ready","dojo/store/Memory", "dojo/parser", "sts/widgets/CustomListItem", "dojox/mobile", "dojo/dom",
"dijit/registry", "dojox/mobile/ScrollableView", "dojox/mobile/TabBar",
"dojox/mobile/TabBarButton", "dojox/mobile/EdgeToEdgeStoreList"], function(ready, Memory, parser) {
ready(function() {
console.log('Dojo ready!');
store = new Memory({
data : [{name:'aaa',surname:'AAA'},{name:'bbb', surname: 'BBB'}],
idProperty : 'name'
});
dijit.registry.byId('list').setStore(store);
});
});
小部件 .js 文件
define(["dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dojox/mobile/ListItem",
"dojo/text!./templates/CustomListItem.html"
],
function(declare, WidgetBase, TemplatedMixin, ListItem, template){
return declare('app.widgets.CustomListItem', [WidgetBase, TemplatedMixin, ListItem],{
templateString: template
});
});
还有小部件的模板:CustomListItem.html
<div>
<div>TEST TEST</div>
</div>
有谁知道为什么如果我在小部件声明(WidgetBase、TemplatedMixin、ListItem)中使用这样的顺序,dojo 会尝试呈现 ListItem 默认模板,但如果我交换 TemplatedMixi 和 ListItem(WidgetBase、ListItem、TemplatedMixin),一切正常正确吗?我什至不知道继承顺序对dojo很重要。
谢谢。
【问题讨论】:
标签: javascript dojo