Ripple Emulator不会触发事件 [英] Ripple Emulator doesn't fire events

查看:139
本文介绍了Ripple Emulator不会触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了最新的Ripple Emulator(Chrome Store中最新版本),一切正常,除了活动。它们都不会触发(不仅 deviceready ,而在其他一些SO问题中,没有)。

I have newest Ripple Emulator installed (newest available in Chrome Store) and everything works just fine, except events. None of them fires (not only deviceready as in some other SO question, none).

既不手动(使用) 事件窗格)也自动( deviceready )被解雇。

Neither manually (using Events pane) nor automatically (deviceready) fired.

当我使用手动方法时,Ripple会向控制台写一行,它正在触发一个事件,但实际上什么也没发生。我的申请根本没有反应。我有 backbutton 事件绑定,它在Ripple中不起作用。当我将其init部分移动到 deviceready 事件时,应用程序停止工作,因为它没有被触发。当然,在目标设备上一切都很好,所以代码应该是正确的。

When I use manual method, Ripple writes a line to the console, that it is firing an event, but nothing actually happens. My application does not react at all. I have backbutton event bind and it is not working in Ripple. And application stopped working at all, when I moved its init part to deviceready event, as it is not being fired. Of course, on target device everything is fine, so code should be correct.

可能导致此类行为的原因是什么?有什么解决方法吗?

What can be causing such behavior and is there any workaround for it?

编辑:我在Windows 7上安装了Chrome扩展程序 Ripple Emulator(Beta)0.9.15 。一切都在目标设备上很好,所以JS代码(事件处理程序)应该没问题。

EDIT: I have Ripple Emulator (Beta) 0.9.15 installed as Chrome Extension on Windows 7. All is just fine on destination device, so JS code (events handlers) should be fine.

推荐答案

经过深入调查后,我已经设法解决了这个问题(至少部分地 - 有些事件被解雇了,有些则没有)。在我的情况下,它是一个缺少 .js (PhoneGap源)文件问题。

After deeper investigation I've managed to solve this problem (at least partially -- some events are fired some are not). In my case it was a missing .js (PhoneGap source) file problem.

成功的关键是to:


  1. 实际上将PhoneGap / Cordova JS 文件放在您的应用内容中并拥有它<

  1. Actually have PhoneGap / Cordova JS file placed in your app content and have it correctly referenced (valid path and file name) in your source files.

源文件正确版本(2.0.0)截至撰写本文时。

Have source file in correct version (2.0.0) as of writing this.

第一次可能特别令人困惑for PhoneGap构建用户,指示删除源文件。源文件中的引用(< script type =text / javascriptsrc =cordova.js>< / script> )应该不受影响,但是文件,它引用,不应该退出。 PhoneGap Build将在编译/构建过程中注入此文件(在适当的版本中)。

First can be especially confusing for PhoneGap Build users, which are instructed to remove source file. Reference in source file (<script type="text/javascript" src="cordova.js"></script>) should be untouched, but file, it references, should not exits. PhoneGap Build will inject this file (in proper version) during compile / build process.

这适用于PhoneGap,但完全错误的Ripple 。如果您希望Ripple功能齐全且能够触发事件(至少是确定的话),您应该保留该文件。我发现,这根本不会干扰PhoneGap。无论是否存在该文件,都可以毫无问题地构建应用。

This is fine for PhoneGap, but completely wrong for Ripple. If you want Ripple to be fully functional and be able to fire events (at least certain), you should leave that file in place. I found out, that this does not interfere PhoneGap at all. Apps are builded without problems, with and without that file in place.

第二也很重要。我发现,当前版本的Ripple是基于 PhoneGap API 2.0.0 ,这对于当前可用的 PhoneGap API 3.0.0 <非常非常老/ A>。因此,要让Ripple几乎没有故障,你必须[浏览PhoneGap存储库( http://phonegap.com/install/ )并获取 PhoneGap 2.0.0 来源,发布 2012年7月20日并提取 cordova.js 文件出来的。然后将它放在你的webapp的源文件夹中,添加正确的引用然后尝试Ripple。

Second is also important. I found out, that current version of Ripple is build basing on PhoneGap API 2.0.0, which is very, very old against currently available PhoneGap API 3.0.0. So, to have Ripple working nearly without glitches, you have to [browse PhoneGap repository(http://phonegap.com/install/) and grab PhoneGap 2.0.0 sources, released 20 Jul 2012 and extract cordova.js files out of it. Then place it in source folder of your webapp, add correct reference to it and try Ripple then.

现在至少应该触发一些事件(有些事件,比如 deviceready )可能仍会失败。

At least some events should now be fired (some, like deviceready) may still fail.

另外,请记住,所有内容,包括事件处理程序,都必须在 deviceready 事件监听器代码中定义,或者整件事都会失败。

Also, keep in mind, that everything, including event handlers, must be defined in a deviceready event listener code, or the whole thing will fail.

Ripple的JIRA问题,可能是相关的:

Ripple's JIRA issues, that might be related:

  • Support for the last version of PhoneGap,
  • Ripple Emulator under Windows doesn't fire events,
  • Ripple should check, if phonegap.js / cordova.js files really exists.

BTW:如果你打开浏览器的控制台并手动发起一个事件,你会看到一个正确的通知由Ripple控制。这意味着,Ripple 认为,如果在模拟的webapp上触发偶数,但它实际上不会触发它

BTW: if you open up browser's console and manually fire an event you'll see a proper notice written to console by Ripple. Which means, that Ripple thinks, if fires an even on an emulated webapp, but it actually doesn't fire it.

这篇关于Ripple Emulator不会触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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