我是Sencha Touch 2& S的新手也是。我有jquery的知识,所以我提到了几个相似的东西,以便快速理解,但在选择器查询中陷入困境。
我正在创建动态文本字段,例如:
var autoSuggestField = 'people_' + counter; // suppose counter is looping 5 times
var field = new Ext.field.Text({
name: autoSuggestField,
itemId: 'testing', // just for testing
// itemId: autoSuggestField, // actual code
inputCls:'auto-suggest',
placeHolder:'Select People',
cls:'place-holder',
listeners: {
clearicontap:function(obj, e, eOpts) {
// tried option 1
var allPeople = Ext.ComponentQuery.query('.place-holder .auto-suggest');
console.log(allPeople); // console says '[]'
// tried option 2
var allPeople = Ext.ComponentQuery.query('.place-holder');
console.log(allPeople); // console says '[]'
// tried option 3
var allPeople = Ext.ComponentQuery.query('.auto-suggest');
console.log(allPeople); // console says '[]'
// tried option 4
var allPeople = Ext.ComponentQuery.query('#testing');
console.log(allPeople); // console says '[class , class, class]'
}
}
});
但我正在寻找一些东西:
// var allPeople = Ext.ComponentQuery.query('[name^=people_]'); // as we do jquery
或类似的东西,应该有效。请清楚我在选项[1,2,3]中做错了,因为大多数帖子都说使用id [option 4]是不好的。我们如何实现使用[name ^ =]"它表示任何以people _"开头的元素。在Ext中有可能吗?是否有可能通过REGEX?(仅仅是为了一个想法)
请添加解释以更好地理解选择器。