如何在Extjs中获取动态html元素的图像

时间:2015-03-06 07:57:39

标签: html extjs

我有一个门户网站(附图),当我点击一个按钮时,我会在面板(右侧)中获得一些图像。现在我想要点击每张图片来获得带有图片ID的警告框。我该如何访问?直到现在我已经使用jquery做了所有事情,现在我正处于迁移过程中。这是我的代码的一部分:

           items: [{
                xtype: 'tabpanel',
                width: 600,
                activeTab: 0,
                flex: 2,
                layout: {type: 'fit'},
                items: [{
                        xtype: 'panel',
                        title: 'Images',
                        items: [{contentEl:'img',autoScroll:true,height:500 }],

                 },{    
                        xtype: 'panel',
                        title: 'Material',
                        items: [{contentEl:'msg',autoScroll:true,height:500 }]
                        }]
            }]..

enter image description here

1 个答案:

答案 0 :(得分:2)

您可以在追加图像元素时添加侦听器

{
    xtype: 'image',
    src: 'some-path',
    listeners: {
        el: {
            click: function() { alert(this.id); }
        }
    }
}