Ti.App.fireEvent 和 eventListener 在静态 html/javascript 中不工作(Titanium Appcelerator - Windows Phone)
Ti.App.fireEvent and eventListener not working in static html/javascript (Titanium Appcelerator - Windows Phone)
我们正在为 android、iOS 和 windows phone 构建一个相当简单的应用程序,我们决定使用 Titanium。
事实证明,Windows Phone 支持目前似乎很糟糕。因为我们需要在所有三个平台上都有一个功能齐全的地图,所以我们开始集成 WebView/leaflet
地图。通信是通过建议的文档 Ti.App.fireEvent
和 Ti.App.addEventListener
完成的,它们在 iOS 和 android 上没有问题,但我们在 windows [=33] 上遇到问题=] 未注册任何事件或在 WebView 中加载的应用程序和网页之间发送任何事件。
面对这个问题,我们会错过什么?
(使用的 SDK 是最新的 5.1.2,windows 8.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/ 检查这是否是已知问题。如果不是,请为该问题创建一个票证 link,但还要在票证本身中提供可重现的代码、步骤和环境信息。别忘了在这里给票打个link,这样其他人就可以和你一起看。
我们正在为 android、iOS 和 windows phone 构建一个相当简单的应用程序,我们决定使用 Titanium。
事实证明,Windows Phone 支持目前似乎很糟糕。因为我们需要在所有三个平台上都有一个功能齐全的地图,所以我们开始集成 WebView/leaflet
地图。通信是通过建议的文档 Ti.App.fireEvent
和 Ti.App.addEventListener
完成的,它们在 iOS 和 android 上没有问题,但我们在 windows [=33] 上遇到问题=] 未注册任何事件或在 WebView 中加载的应用程序和网页之间发送任何事件。
面对这个问题,我们会错过什么?
(使用的 SDK 是最新的 5.1.2,windows 8.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/ 检查这是否是已知问题。如果不是,请为该问题创建一个票证 link,但还要在票证本身中提供可重现的代码、步骤和环境信息。别忘了在这里给票打个link,这样其他人就可以和你一起看。