如何按类别点击图像上的事件或fireEvent?

时间:2015-04-22 21:41:11

标签: javascript jquery html extjs

我可以根据他们的课程点击图片吗? jquery中的示例是$(.imageID).click();

<img src="picture.png" class="imageClass">

如何点击EXT JS 5+中的事件或火灾事件?

3 个答案:

答案 0 :(得分:0)

Ext.select('.imageClass').each(function(item){
     item.fireEvent('click', item); 
});

应在类.imageClass

的每个元素上触发click事件

答案 1 :(得分:0)

您可以使用Ext.select()来获取您所追求的行为。

Ext.select('.pic').on('click', function() { alert('Mew!'); }); 
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/4.2.1/ext-all.min.js"></script>
<img src="https://placekitten.com/g/200/300" class="pic" />

答案 2 :(得分:0)

Firing UI events programmatically is very, very bad practice, unless you are testing the application. So if you are not testing, just call the handler directly and do not simulate clicks this way.