【发布时间】:2016-10-23 14:39:21
【问题描述】:
这是我的自定义 ListItem 模板:
var template =
"<div>" +
" <div style='display: inline;' data-dojo-attach-point='labelNode'></div>" +
" <div data-dojo-type='dojox/mobile/Badge' data-dojo-props='value:${size}' style='display: inline; position: absolute; right: 100px;'></div>" +
"</div>";
正确创建了html,即:
<div data-dojo-type="dojox/mobile/Badge" data-dojo-props="value:37" style="display: inline; position: absolute; right: 100px;"></div>
但它在页面上不可见。 我尝试将完全相同的代码放在页面的其他位置,它可以工作。
更新
其他一些代码和信息。
我有一个dojox/mobile/EdgeToEdgeStoreList,我想使用我的自定义ListItem 而不是默认的。例如,我在一个属性上设置了background-color,我想用Badge 替换原来的rightText。
这是CustomListItem的完整代码:
define([
"dojox/mobile/ListItem",
"dijit/_TemplatedMixin",
"dojox/mobile/Badge",
"dojo/_base/declare"
], function (ListItem, TemplatedMixin, Badge, declare) {
var template =
"<div class='areaDone${done}'>" +
" <div style='display: inline;' data-dojo-attach-point='labelNode'></div>" +
" <div data-dojo-type='dojox/mobile/Badge' data-dojo-props='value:${size}' style='display: inline; position: absolute; right: 100px;'></div>" +
"</div>";
TemplatedListItem = declare("CustomListItem",
[ListItem, TemplatedMixin], {
label: "My label",
size: "0",
templateString: template
}
);
});
这里是html(玉)代码:
h2(data-dojo-type="dojox.mobile.RoundRectCategory") List
#panel(data-dojo-type="dojox/mobile/ScrollablePane")
ul#list(data-dojo-type="dojox/mobile/EdgeToEdgeStoreList" data-dojo-props="itemRenderer: CustomListItem, itemMap: {Desc: 'label', size: 'size'}, select: 'single'")
最后是用来填充列表的js:
store = new Memory({data: JSON.parse(data), idProperty: "Desc"});
list.setStore(store);
【问题讨论】:
-
您正在使用/创建小部件吗?你能发布一段你的 js/widget 的代码吗?
-
我只是想在 EdgeToEdgeStoreList 中使用我的自定义 ListItem。我将在我的问题中添加一些其他代码。如果还不够,请询问!
标签: mobile dojo listitem badge