The-M-Project
The-M-Project copied to clipboard
wrong currentPage after using ToolBarView's back-button
When defining a back-button in the ToolBarView, the getCurrentPage() method in M.ViewManager is returning the wrong view. This is because the event on the back-button is defined as such:
internalEvents: {
tap: {
action: function() {
history.back(-1);
}
}
}
The M.ViewManager.setCurrentPage(..) method is not invoked when a page is rendered and therefore will not update the currentPage property.
A current workaround is possible by invoking the setCurrentPage manually when the "pageshow" event is fired:
M.ViewManager.setCurrentPage(M.ViewManager.getViewById($('div.ui-page-active')[0].id));
Well, this "automatic back button" feature is kind of a relict from the early stages of The-M-Project. When we develop a mobile app today, we add a custom navigation behavior that typically includes a back button.
Even though each app will have its own custom navigation behavior, there are a few things in common for most apps. But so far we weren't able to figure out a generic concept we can provide with The-M-Project.