0
我有jQuery中下面的代碼,當您文本輸入到一個文本框(#searchServices
),它會淡出不包含文本鏈接,它會在不含該文本鏈接褪色。高級選擇在ExtJS的
我怎樣才能做到這一點的ExtJS的?
$('#searchServices').keyup(function() {
if ($(this).val().trim() != '') {
$('.serviceGridItem:not(:contains("' + $(this).val() + '"))').fadeOut();
$('.serviceGridItem:contains("' + $(this).val() + '")').fadeIn();
}
else {
$('.serviceGridItem').fadeIn();
}
})
現在,我有我的文本框和我的聽衆,像這樣:
xtype: 'textfield',
enableKeyEvents: true,
listeners: {
keyup: function(c) {
console.log(c.getValue());
}
}
我的(產生的)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>
編輯:我曾嘗試這但我得到和說,「意外的標識符」的錯誤。
Ext.query('.serviceGridItem:not(:contains("' + c.getValue() + '"))').hide();
相同的結果之一。請注意,我並不是想要獲取所有元素,只是包含HTML中某些文本的元素。 – user1477388
對可能的解決方法請參見編輯 – lascort
由於這是有幫助的。我會接受這個作爲一個答案,但它吮吸的是ExtJS的傾斜只是做'Ext.query隱藏();(」「+ c.getValue()+ '」))' serviceGridItem:沒有(包含(」)。 '。看來ExtJS不支持這樣的嵌套選擇器。我張貼另一個問題有一個更具體的例子,這裏的jsfiddle http://stackoverflow.com/questions/21785001/extjs-bug-selector-not-working-properly – user1477388