Sencha Touch:[未定义] 不是一个函数
我尝试使用 Sencha Touch 按类名获取元素,
itemswipe: function(dataview, index, element, e) {
console.log(element.select('.x-list-disclosure'));
}
但它返回此错误:
类型错误:表达式“element.select”[未定义]的结果不是函数。
这是完整的代码块
var list1 = new Ext.List({
flex: 1,
cls: 'list_simple',
sorters: ['firstName', 'group'],
itemTpl: '{firstName} {lastName}',
grouped: true,
groupTpl : [
'<tpl for=".">',
'<div class="x-list-group x-group-{id}">',
'<h3 class="x-list-header"><div class="header">{group}</div></h3>',
'<div class="x-list-group-items">',
'{items}',
'</div>',
'</div>',
'</tpl>'
],
onItemDisclosure: function(record, btn, index) {
Ext.Msg.alert('Tap', 'Disclose more info for ' + record.get('firstName') + ' ' + record.get('lastName'), Ext.emptyFn);
},
listeners: {
itemtap: function(dataview, index, element, e) {
console.log('node is tapped');
},
itemswipe: function(dataview, index, element, e) {
console.log(element.select('.x-list-disclosure'));
}
},
store: store
});
(已添加)这是 {items}
生成的元素:
<div class="x-list-group-items">
<div class="x-list-item x-item">
<div class="x-list-item-body">Melvin Gilbert</div>
<div class="x-list-disclosure"></div>
</div>
<div class="x-list-item x-item">
<div class="x-list-item-body">Jeaffrey Gilbert</div>
<div class="x-list-disclosure"></div>
</div>
</div>
有什么想法吗?
I'm trying to get element by class name with Sencha Touch
itemswipe: function(dataview, index, element, e) {
console.log(element.select('.x-list-disclosure'));
}
but it returns this error:
TypeError: Result of expression 'element.select' [undefined] is not a function.
Here is the full code block
var list1 = new Ext.List({
flex: 1,
cls: 'list_simple',
sorters: ['firstName', 'group'],
itemTpl: '{firstName} {lastName}',
grouped: true,
groupTpl : [
'<tpl for=".">',
'<div class="x-list-group x-group-{id}">',
'<h3 class="x-list-header"><div class="header">{group}</div></h3>',
'<div class="x-list-group-items">',
'{items}',
'</div>',
'</div>',
'</tpl>'
],
onItemDisclosure: function(record, btn, index) {
Ext.Msg.alert('Tap', 'Disclose more info for ' + record.get('firstName') + ' ' + record.get('lastName'), Ext.emptyFn);
},
listeners: {
itemtap: function(dataview, index, element, e) {
console.log('node is tapped');
},
itemswipe: function(dataview, index, element, e) {
console.log(element.select('.x-list-disclosure'));
}
},
store: store
});
(Added) This is the generated elements of {items}
:
<div class="x-list-group-items">
<div class="x-list-item x-item">
<div class="x-list-item-body">Melvin Gilbert</div>
<div class="x-list-disclosure"></div>
</div>
<div class="x-list-item x-item">
<div class="x-list-item-body">Jeaffrey Gilbert</div>
<div class="x-list-disclosure"></div>
</div>
</div>
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过调用 Ext.fly 来包装您的元素变量,它将为您提供 dom 元素的 Ext.Element 表示形式。 element 变量是一个 DOM 节点而不是一个 Ext.Element 实例。所以就变成了 Ext.fly(element).select('..')
Wrap your element variable with a call to Ext.fly and it will give you an Ext.Element representation of the dom element. The element variable is a DOM node rather than an Ext.Element instance. So it becomes Ext.fly(element).select('..')