通过双击图像调用函数

时间:2013-03-31 11:51:42

标签: extjs4.1

我使用ExtJS 4检索特定id的图像并显示为数据视图。现在我需要通过dbl单击图像来调用函数。

Ext.define('${pkgName}.v02x003001.SV02X00300102', {
    extend: 'Ext.view.View',
    alias: 'widget.sv02x00300102',
    id: 'images-view',
    autoScroll: true,
    trackOver: true,
    multiSelect: true,
    height: 180,
    overItemCls: 'x-item-over',
    itemSelector: 'div.thumb-wrap',
    emptyText: 'No images to display',
    prepareData: function (data) {
        Ext.apply(data, {
            shortName: Ext.util.Format.ellipsis(data.name, 15),
            sizeString: Ext.util.Format.fileSize(data.size),
            dateString: Ext.util.Format.date(data.lastmod, "m/d/Y g:i a")
        });
        return data;
    },
    initComponent: function () {
        var me = this;
        var member = Ext.getCmp('member-sv02x00300104').getValue();
        me.store = 'S02X003001';
        me.tpl = [
            '<tpl for=".">',
            '<div class="thumb-wrap" id="{name}">',
            '<div class="thumb">
            <img  src="${createLink(mapping:'
        img ', params:[])}/{id}/100/100/" title="{id}">
                   </div>',
            '<span class="x-editable">{name}</span></div>',
            '</tpl>',
            '<div class="x-clear"></div>'];

        me.callParent(arguments);
    }
});

1 个答案:

答案 0 :(得分:1)

此代码是否符合您的需求(doc here)?

listeners: {
    itemdblclick: function (view, record, item, index, e) {
        if (Ext.get(e.getTarget()).is('img')) {
            alert('you double clicked an image');
        }
    }
}