In the following docs for onsen it shows that the setMainPage function has an optional property that allows you to specify a callback:
http://onsen.io/reference/ons-sliding-menu.html#method-setMainPage
It doesn't seem to work though, my callback doesn't appear to get fired. There are no errors or anything it just doesn't fire the callback. Here is my code:
<!doctype html>
<html lang="en" ng-app="app">
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>My App</title>
<link rel="stylesheet" href="../lib/onsen/css/onsenui.css">
<link rel="stylesheet" href="../styles/onsen-css-components-blue-basic-theme.css">
<link rel="stylesheet" href="../styles/app.css"/>
<script src="../lib/onsen/js/angular/angular.js"></script>
<script src="../lib/onsen/js/onsenui.js"></script>
<script src="../../cordova.js"></script>
<script>
var module = angular.module('app', ['onsen']);
function show_hide() {
console.log("Fired");
}
</script>
</head>
<body>
<ons-navigator title="Navigator" var="myNavigator">
<ons-sliding-menu menu-page="menu.html" main-page="page1.html" side="left" var="menu" type="reveal" max-slide-distance="400px" swipable="true"></ons-sliding-menu>
<ons-template id="menu.html">
<ons-page modifier="menu-page">
<ons-toolbar modifier="transparent"></ons-toolbar>
<ons-list class="menu-list">
<ons-list-item class="menu-item" ng-click="menu.setMainPage('english/about-this-guidance.html', { closeMenu: true, callback: show_hide() })">
<ons-icon icon="fa-chevron-right"></ons-icon>
About this practice guidance
</ons-list-item>
</ons-list>
</ons-page>
</ons-template>
<ons-template id="page1.html">
<ons-navigator title="Navigator" var="myNavigator">
<ons-page>
<ons-toolbar>
<div class="center">Home</div>
<div class="right">
<ons-toolbar-button ng-click="menu.toggle()">
<ons-icon icon="ion-navicon" size="28px" fixed-width="false"></ons-icon>
</ons-toolbar-button>
</div>
</ons-toolbar>
<ons-row>
<ons-col align="left">
<h1>Home</h1>
</ons-col>
</ons-row>
</ons-page>
</ons-navigator>
</ons-template>
</ons-navigator>
</body>
</html>
Interestingly if I do the following:
<ons-list-item class="menu-item" ng-click="menu.setMainPage('english/about-this-guidance.html', { closeMenu: true, callback: 'show_hide()' })">
Then it will error because I'm passing a string when its expecting a function, so the callback does seem to be registering it just doesn't fire