This is indeed not working after Onsen UI 1.3.0. The reason is an event.stopPropagation()
that is executed in ons-navigator
to avoid other problems (https://github.com/OnsenUI/OnsenUI/blob/master/core/lib/navigator-page.es6#L43). Perhaps this will change in next versions. Github issue for more info here: https://github.com/OnsenUI/OnsenUI/issues/865
ons-back-button
is just triggering myNavigator.popPage()
, so meanwhile I would suggest you to use myNavigator.on('prepop', listener)
or myNavigator.on('postpop', listener)
: http://onsen.io/reference/ons-navigator.html#events-summary
Edit: Two workarounds for this.
1 - As I said before, set a listener with a callback after postpop
(should be the same than onTransitionEnd
:
myNavigator.once('postpop', callback)
You can use on
if you want the same callback always or once
if only once. Also check off
to remove listeners if you don't need them anymore. For example, you can set a specific callback for pageX in its initialization with once
that it will be "consumed" with the back button. If in pageX you can push more pages, you can just use nav.off('postpop', callback); nav.pushPage(pageY)
.
2 - Using only the style of back-button instead of the real component, so you can use onclick
normally:
<style>
.ons-back-button__icon {
vertical-align: top;
font-size: 36px;
margin-left: 8px;
margin-right: 2px;
width: 16px;
display: inline-block;
padding-top: 1px;
}
</style>
<ons-toolbar-button class="toolbar-button--quiet" onclick="myNavigator.popPage(options)">
<ons-icon class="ion-ios-arrow-back ons-back-button__icon"></ons-icon>
Back
</ons-toolbar-button>
Hope it helps!