How to determine that I'm back on index page in framework7

535 Views Asked by At

Inside my index.html, I have this button that goes to about.html when tapped.

<div class="col-50">
    <a href="about.html">
        <div class="button">About</div>
    </a>
</div>

And on about page, I would like to detect whenback button is tapped and that I am now on my index.html page.

Here's what I've tried:

First attempt:

myApp.onPageInit('index', function (page) {
    myApp.alert("test");
});

Second attempt:

myApp.onPageInit('index', function (page) {
    myApp.alert("test");
}).trigger();
1

There are 1 best solutions below

1
On BEST ANSWER

Did you try:

myApp.onPageBack("about", function() {
  myApp.alert("test");
});

Do not forget the data-page="about" attribute in your about page.

  <div class="pages">
    <div class="page" data-page="about">
      <div class="page-content">
        ... page content goes here ...
      </div>
    </div>
  </div>