[英]Capture long press or tap hold event of grid row in Ext JS
我正在使用grid的rowcontextmenu事件在右鍵單擊上顯示一些選項,在桌面上運行良好。 我想在iPad上長按實現相同的功能,但是我在sencha docs中發現了任何此類事件。 我嘗試了jquery長按插件,但無法實現。 我正在使用Ext JS 3.4版本。 有任何提示請。
這些偵聽器(至少)必須應用於Ext.grid.RowSelectionModel ,以便將這些事件正確綁定在該特定范圍內。 看到這篇博客文章 ; 還有更多的DOM事件類型需要考慮。 你正在尋找要么稱為事件taphold
或longpress
(見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() ,可以僅定義任何缺少的框架事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.