Sencha Touch 2 - 防止a-href事件(a-href事件处理) [英] Sencha Touch 2 - prevent a-href events (a-href event handling)

查看:158
本文介绍了Sencha Touch 2 - 防止a-href事件(a-href事件处理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Sencha Touch 2应用程序中,我需要自己处理重定向事件。

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,stopPropagatioon,preventDefault)。应用程序总是在我的应用程序网络视图中打开链接。

By none of the above mentioned functions work (stopEvent, stopPropagatioon, 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆