ons-sliding-menu
当用户按下android的后退按钮时,我想关闭。我怎样才能做到这一点?目前的实现是:
var manager = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function(){
document.addEventListener("backbutton", manager.onBackKeyDown, false);
document.addEventListener("menubutton", manager.onMenuKeyDown, false);
},
onBackKeyDown: function(){
// close ons-sliding-menu if opened
},
onMenuKeyDown: function(){
// close or open ons-sliding-menu
}
};
manager.initialize();
我试过打电话ons.slidingMenu.toggleMenu()
,但是ons
当事件触发undefined
时。onBackKeyDown