-1

我已经设置了一个 XTemplate 来为不同的列表项显示不同的样式,具体取决于它们的类型。我还想为每种不同的类型设置不同的公开按钮。我可以使用以下方法将所有披露按钮设置为自定义图像:

.x-list-item .x-list-disclosure {
overflow: visible;
-webkit-mask: 0 0 url(path/to/image) no-repeat;
}

但我找不到更改单个披露按钮的方法。我尝试在 XTemplate 中定义一个自定义类,即:

var solutiontpl = new Ext.XTemplate (

            "</pre>",
            "<div class = 'solution-container'>",
                "<div class = 'list-item-title'>",
                    '<tpl if = "type == \'p\'">',
                    "{title}<span class = 'solution-rating-text'>{rating}</span>",
                    "<span class = 'partner-icon'></span>",
                    '</tpl>',
                    '<tpl if = "type == \'a\'">',
                    "{title}<span class = 'solution-rating-text'>{rating}</span>",
                    '</tpl>',
                    '<tpl if = "type == \'s\'">',
                    "{title}<span class = 'solution-rating-text'>{rating}</span>",
                    '</tpl>',
                "</div>",
            "</div>",
            "<pre>"
);

并尝试使用“.solution-container .x-list-item .x-list-disclosure”将公开按钮设置为无效。我怎么能这样做呢?

4

1 回答 1

0

.solution-container .x-list-item .x-list-disclosure不起作用,因为具有类的元素.solution-container实际上是具有类的元素的子元素.x-list-item

下面是 DOM 的样子:

<div class="x-list-item ">
    <div class="x-list-item-body">
        <div class="solution-container">
        ....
        .... your itemTpl here
        ....
        </div>
    </div>
    <div class="x-list-disclosure"></div>
</div>

为了让它正确,您应该为Ext.List配置设置一个 ID(Sencha Touch 1.1):

var myList = new Ext.extend(Ext.List, {
    id: 'SpecialDisclosureList',
    store: MyStore,
    itemTpl: '<div> ... tpl ... </div>',
    onItemDisclosure: true
});

(煎茶触摸 2):

Ext.create('Ext.List', {
   id : 'SpecialDisclosureList',
   itemTpl: '<div> ... tpl ... </div>',
   store: MyStore
   onItemDisclosure: true
});

将 ID 设置为 后Ext.List,以下 css 样式将起作用:

#SpecialDisclosureList.x-list .x-list-disclosure {
    overflow: visible;
    -webkit-mask: 0 0 url(path/to/image) no-repeat;
}
于 2012-11-19T10:03:51.783 回答