涟漪模拟器不会触发事件 [英] Ripple Emulator doesn't fire events

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

问题描述

我安装了最新的Ripple Emulator(Chrome商店中提供了最新版本),除事件外,其他所有功能都正常运行.它们都不触发(不仅像其他一些SO问题一样, deviceready 也没有触发).

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).

既不手动(使用 Events 窗格)触发,也不自动( deviceready )触发.

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

当我使用手动方法时,Ripple在控制台上写了一行,它正在触发一个事件,但是实际上什么也没发生.我的应用程序根本不响应.我有 backbutton 事件绑定,它在Ripple中不起作用.当我将其初始化部分移至 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上安装了 Ripple Emulator(Beta)0.9.15 作为Chrome扩展程序.在目标设备上一切正常,因此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.

成功的关键是:

  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.

第一对于PhoneGap Build用户而言尤其令人困惑,这些用户被指示删除源文件.源文件中的引用(< script type ="text/javascript" src ="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 .因此,要使Ripple几乎无故障运行,您必须[浏览PhoneGap信息库( http://phonegap.com/install/)并获取 PhoneGap 2.0.0 来源,并于2012年7月20日发布 ,并从其中提取 cordova.js 文件.然后将其放在您的Web应用程序的源文件夹中,为其添加正确的引用,然后尝试使用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:

顺便说一句:如果您打开浏览器的控制台并手动触发事件,您会看到Ripple写入控制台的适当通知.这就是说,Ripple会思考,如果在模拟的Web应用程序上触发了偶数,而实际上却没有触发.

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.

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

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