原理:通过使用Ext.select()方法选中list中选中的item的元素
Sencha Touch 交流 QQ 群 224711028 欢迎您的加入。
文档源代码:
//get my view, which is just a sized down Ext.Sheet
varview = this.getItemMenuView().create();
//note that the quotes around the itemindex value here are required to include and don't seem to be in the sencha docs; this function was failing until I included the quotes
varitemEl = Ext.select("div.x-list-item[itemindex=\""+ idx + "\"]", listCmp.getId() );
//I know that the array returned by Ext.select above will only ever be a single element array, so we just grab the first element here
varel = itemEl.first();
varx = el.getX();
vary = el.getY();
varsize = el.getSize();
x = x + size.width / 2;
y = y + size.height;
view.setTop(y);
view.setLeft(10);
view.show();
}
获得element后我们可以对元素进行附加样式的操作:
varitemEl = Ext.select(".x-item-selected", myApp.getSectionList().getId() );
varel = itemEl.first();
console.log(itemEl);
console.log(el);
Ext.get(el).addCls('search-item-active');
附:Ext.select方法API:
Selects elements based on the passed CSS selector to enable Element methods to be applied to many related elements in one statement through the returned CompositeElementLite object.
Parameters
- selector : String/HTMLElement[]
The CSS selector or an array of elements
- root : HTMLElement/String (optional)
The root element of the query or id of the root