Sencha Touch 2 - 防止 a-href 事件(a-href 事件处理) [英] Sencha Touch 2 - prevent a-href events (a-href event handling)
本文介绍了Sencha Touch 2 - 防止 a-href 事件(a-href 事件处理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 Sencha Touch 2 应用程序中,我需要自己处理重定向事件.我的意思是我需要能够处理 href 事件并自己进行重定向.
In my Sencha Touch 2 application I need to handle redirection events on my own. By this I mean I need to be able to handle a href events and do the redirection myself.
我正在使用以下代码:
Ext.Viewport.element.addListener("tap", function(e) {
e.stopEvent();
e.stopPropagation();
e.preventDefault();
var href = e.target.getAttribute("href");
// ... my code ...
}, this, {delegate: "a"});
以上提到的函数都不起作用(stopEvent
、stopPropagation
、preventDefault
).该应用程序始终在我的应用程序 Web 视图中打开该链接.
By none of the above mentioned functions work (stopEvent
, stopPropagation
, preventDefault
). The application always opens the link in my app web view.
这里有什么方法可以禁用 href 打开链接吗?
Is here any possible way to disable a href opening links?
推荐答案
我通常是这样的:
Ext.Viewport.element.dom.addEventListener('click', function (e) {
if (e.target.tagName !== 'A') {
return;
};
e.preventDefault();
var href = e.target.getAttribute('href');
}, false);
希望这有帮助
这篇关于Sencha Touch 2 - 防止 a-href 事件(a-href 事件处理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文