Javascript 使用phonegap/cordova单击android本机菜单按钮,启动jquery移动面板菜单

Javascript 使用phonegap/cordova单击android本机菜单按钮,启动jquery移动面板菜单,javascript,android,jquery,jquery-mobile,cordova,Javascript,Android,Jquery,Jquery Mobile,Cordova,我正在使用Jquery Mobile/Phonegap开发一个Android应用程序。我有以下代码来控制手机的菜单按钮: <script type="text/javascript" charset="utf-8"> // Call onDeviceReady when PhoneGap is loaded. // // At this point, the document has loaded but phonegap-1.0.0.js has not

我正在使用Jquery Mobile/Phonegap开发一个Android应用程序。我有以下代码来控制手机的菜单按钮:

 <script type="text/javascript" charset="utf-8">

    // Call onDeviceReady when PhoneGap is loaded.
    //
    // At this point, the document has loaded but phonegap-1.0.0.js has not.
    // When PhoneGap is loaded and talking with the native device,
    // it will call the event `deviceready`.
    // 
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // PhoneGap is loaded and it is now safe to make calls PhoneGap methods
    //
    function onDeviceReady() {
        // Register the event listener
        document.addEventListener("menubutton", onMenuKeyDown, false);
    }

    // Handle the menu button
    //
    function onMenuKeyDown() {

    alert("It works");
    }

    </script>   
我在身体标签上加了:

<body onload="onLoad()"> 
因此,当我点击android原生菜单按钮时,我会收到一条警告消息,它可以工作。。。我想知道我需要添加哪种代码来调用基于jquery mobile创建的菜单。以下是菜单面板的代码:

<div data-role="panel" id="mypanel" data-display="overlay">

<ul data-role="listview" class="fondo">
<li data-icon="false"><a href="#menu" class="menutxt" data-transition="slide"><img class="ui-li-icon" src="./img/history.svg">Option 1</a></li>
<li data-icon="false"><a href="#menu" class="menutxt" data-transition="slide"><img class="ui-li-icon" src="./img/pizza.svg">Option 2</a></li>
<li data-icon="false"><a href="#menu" class="menutxt" data-transition="slide"><img class="ui-li-icon" src="./img/tag.svg">Option 3</a></li>
<li data-icon="false"><a href="#combina" class="menutxt" data-transition="slide"><img class="ui-li-icon" src="./img/cart.svg">Option 4</a></li>
</ul>

</div>

谢谢你调查此事。。非常感谢您的帮助。

这些是您可以用于JQM中面板的所有选项/事件/方法

打开您的面板


你好,塔索斯!非常感谢你在这方面帮助我。这正是我需要的。。。我继续并实现了切换方法,该方法允许在单击按钮时显示和隐藏。比如$mypanel.panel打开;在上面的评论中,我指的是$mypanel.panel-toggle;
$( "#mypanel" ).panel( "open" );