我正在使用grid的rowcontextmenu事件在右键单击上显示一些选项,在桌面上运行良好。我想在iPad上长按实现相同的功能,但是我在sencha docs中发现了任何此类事件。我尝试了jquery长按插件,但无法实现。
我正在使用Ext JS 3.4版本。有任何提示请。

最佳答案

这些监听器(至少)必须应用于Ext.grid.RowSelectionModel,以便将这些事件正确绑定在该特定范围内。看到这个blog article;还有更多的DOM事件类型需要考虑。您要查找的事件称为tapholdlongpress(请参阅Safari文档中的“处理事件”)。

RowSelectionModel的事件可以定义如下:

new Ext.grid.GridPanel({

    /**
     * one has to instance the default row-selection model explicitly,
     * in order to be able to configure it's event listeners ...
    **/
    sm: new Ext.grid.RowSelectionModel({
        singleSelect: true,
        listeners: {

            taphold: 'rowcontextmenu'

        }
    })

});


也可以使用Ext.util.Observable调试事件;这很方便,尤其是在使用过时的框架时(在该框架中已经支持该功能的地方相当可疑)。

// to intercept all events:
Ext.util.Observable.prototype.fireEvent =
Ext.util.Observable.prototype.fireEvent.createInterceptor(function() {
    console.log(this.name);
    console.log(arguments);
    return true;
});

// to capture the events of a particular component:
Ext.util.Observable.capture(
    Ext.getCmp('my-grid-component'), function(event) {
        console.info(event);
    }
);


使用Ext.EventManager.addListener().on(),可以仅定义任何缺少的框架事件。

10-07 14:10
查看更多