“backbutton”事件不会触发 [英] "backbutton" event won't fire

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

问题描述

我正在尝试为Windows Phone 7建立一个phonegap应用程序。我试图关注backbutton事件的文档(http://docs.phonegap.com/en/2.0.0/cordova_events_events.md。 html#backbutton),但我似乎不能让它工作。

I am attempting to build a phonegap app for Windows Phone 7. I am trying to follow the documentation for the "backbutton" event (http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#backbutton), but I can't seem to get it to work.

deviceready事件触发,但backbutton事件不会。当在Visual Studio Windows Phone模拟器中编译和运行时,onDeviceReady函数被调用并记录了设备就绪,但是当按下模拟器返回按钮时,应用程序退出,并且控制台中不记录任何内容。
当按下后退按钮时,应该运行OnBackKeyDown函数。

The "deviceready" event fires, but the "backbutton" event does not. When compiling and running in Visual Studio Windows Phone emulator the onDeviceReady function is called and "Device ready" is logged, but when the emulator back button is pressed the application exits and nothing is logged in the console. When the back button is pressed the OnBackKeyDown function should run.

从正式文档中复制代码:

copy of the code from the offical doc:

<html>
    <head>     
        <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
        <script type="text/javascript">
            function onLoad() {
                document.addEventListener("deviceready", onDeviceReady, false);
            }
            function onDeviceReady() {
                console.log("Device ready");
                document.addEventListener("backbutton", onBackKeyDown, false);
            }
            function onBackKeyDown() {
                console.log("Back button pressed");
            }
        </script>
    </head>
    <body onload="onLoad()">
        <div></div>
    </body>
</html>


推荐答案

https://github.com/purplecabbage/incubator-cordova-wp7/commit/d04b87abb3c3822ef25438e1353a1d7d2e0d6628

您需要等待2.1.0下周初发布,或者在此期间从源代码构建您的应用程序。

You will need to wait for 2.1.0 to be released early next week, or build your app from source-code, in the meantime.

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

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