ExtJs Bug?选择器无法正常工作 [英] ExtJs Bug? Selector not working properly
问题描述
看起来这个选择器在ExtJS中不起作用:
It appears that this selector is not working in ExtJS:
Ext.select('.serviceGridItem:not(:first)')
它正在选择所有项目,而只应选择最后三个(有四个总)。请参阅下面的jsfiddle,并查看您的控制台的结果。
It is selecting all items, whereas it should only select the last three (there are four total). See the jsfiddle linked below and look at your console for the result.
这是结果:
Ext.select('.serviceGridItem')
constructor {elements: Array[4], el: constructor, self: function, superclass: Object, config: emptyFn…}
Ext.select('.serviceGridItem:first')
constructor {elements: Array[1], el: constructor, self: function, superclass: Object, config: emptyFn…}
Ext.select('.serviceGridItem:not(:first)')
constructor {elements: Array[4], el: constructor, self: function, superclass: Object, config: emptyFn…}
这是HTML:
<div class="x-component x-window-item x-component-default" id="dataview-1049" tabindex="-1" style="">
<a href="#" class="serviceGridItem">Legal Compliance</a>
<a href="#" class="serviceGridItem">Departure Package</a>
<a href="#" class="serviceGridItem">House Search</a>
<a href="#" class="serviceGridItem">Language Training</a>
</div>
JavaScript:
The JavaScript:
Ext.onReady(function () {
console.log(Ext.select('.serviceGridItem'));
console.log(Ext.select('.serviceGridItem:first'));
console.log(Ext.select('.serviceGridItem:not(:first)')); // should return Array[3] not Array[4]
});
JSFiddle(在您的控制台中查看结果):
The JSFiddle (look in your console for the result):
这是一个错误,还是有什么我做错了?
Is this a bug or is there something I am doing wrong?
推荐答案
不能真正地告诉你如何使用:first
伪选择器。它不是CSS3标准的一部分,我认为它是通过 jQuery 引入的。 ExtJS显然似乎以某种方式解释,但是在文档中找不到任何东西。
I can't really tell you how the :first
pseudo-selector is supposed to behave. It's not part of the CSS3 standard and I think it was introduced with jQuery. ExtJS apparently seems to interpret it in some way, but I couldn't find anything about it in the docs.
但是,您可以尝试使用CSS3 :first-child
选择器:
However, you could try using the CSS3 :first-child
selector:
Ext.select('.serviceGridItem:not(:first-child)');
似乎在你的小提琴中工作正常: http://jsfiddle.net/k4ggq/6/
which seems to work just fine in your fiddle: http://jsfiddle.net/k4ggq/6/
这篇关于ExtJs Bug?选择器无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!