【问题标题】:Ti.App.fireEvent and eventListener not working in static html/javascript (Titanium Appcelerator - Windows Phone)Ti.App.fireEvent 和 eventListener 在静态 html/javascript 中不起作用(Titanium Appcelerator - Windows Phone)
【发布时间】:2016-05-09 16:21:34
【问题描述】:

我们正在为 android、iOS 和 windows phone 构建一个相当简单的应用程序,我们决定使用 Titanium。

事实证明,目前 Windows Phone 支持似乎相当糟糕。因为我们需要在所有三个平台上都有一个功能齐全的地图,所以我们集成了WebView/leaflet 地图。通信是通过建议的文档Ti.App.fireEvent 和Ti.App.addEventListener 完成的,它们在 iOS 和 android 上都没有问题,但是我们遇到了 windows phone 的问题,它没有注册任何事件或在 WebView 中加载的应用程序和网页之间发送任何事件。

面对这个问题,我们会错过什么?

(使用的 SDK 是最新的,所以 5.1.2,windows 8.1)

【问题讨论】:

    标签: webview windows-phone-8.1 titanium


    【解决方案1】:

    你能用下面的示例代码吗

    “logging.html”

    <html>
        <head>
             <script>
                 Ti.App.addEventListener("app:fromTitanium", function(e) {
                    alert(e.message);
                 });
             </script>
        </head>
        <body>
             <button onclick="Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium'    });">fromWebView</button>
        </body>
    </html>
    

    “app.js”

    var win = Ti.UI.createWindow();
    var webview = Ti.UI.createWebView({
    url: 'logging.html'
    });
    var button = Ti.UI.createButton({
    title: 'fromTitanium',
    height: '50dp',
    width: '130dp'
    });
    button.addEventListener('click', function(e) {
    Ti.App.fireEvent('app:fromTitanium', { message: 'event fired from    Titanium, handled in WebView' });
    });
    Ti.App.addEventListener('app:fromWebView', function(e) {
    alert(e.message);
    });
    win.add(webview);
    win.add(button);
    win.open();
    

    在您的项目中创建一个文件名“logging.html”并将 html 代码放入其中。并将代码放到“app.js”中。

    如果错误仍然存​​在,请在https://jira.appcelerator.org/ 检查这是否是一个已知问题。如果不是,请创建票证,链接到此问题,但还要在票证本身中提供可重现的代码、步骤和环境信息。不要忘记在此处放置门票链接,以便其他人可以与您一起观看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 1970-01-01
      相关资源
      最近更新 更多