Just like the facebook app I want to close all open pages/popups etc and return to root when a user clicks on the navigation (toolbar) button off the view that is currently open.
I’ve managed this but it doesn’t work as I want when a user navigates. I still want to have the pages open when a user navigates between views. But only close all pages/popups when a user clicks on the navigation button of the view that is currently open.
This doesn’t work:
<div class="toolbar tabbar toolbar-bottom">
<div class="toolbar-inner">
<a href="#view-news" class="tab-link tab-link-active" data-selector=".view-main"><span class="icon-News"></span></a>
</div>
</div>
$(document).on("click",".toolbar-inner a.tab-link", function(){
if ($(this).attr("data-selector") === f7app.views.current.router.view.selector) {
// Clear History to Root
f7app.views.current.router.clearPreviousHistory();
// Go to Root
f7app.views.current.router.back();
}
});
Part 1: When the user clicks on the view’s icon, the view history clears and returns to view’s home page. (Not touching any of the other views)
Part 2: ?
I have a toolbar with buttons. When I click a button I go to the chosen view tab. When a page is open within this view and I navigate away and come back the page is still open. This should be and I’m satisfied about this.
When I’m in a view tab and have pages opened within this view I want to close all open pages when I click on the view button of the same view.
@nolimits4web I think at the moment, view change happens before ‘click’ event is fired to the tab button right? So if you check if the tab is the same, it will always match current, even when changing from another tab.
@Dopey should there be an event that fires before tab change, you may use this to put clearing DOM and cache + go back to home page in 1 line: