Go Back To Previous Page

In my app, I listen to offline and online events using the cordova network plugin… I fire a toast on offline and redirect using app.navigate('/to-no-network-page/'). I want that once network comes back, I immediately redirect user to their previous page in history… I have found router.back(); but it’s not working as I dont know how to use it…

$$(document).on(‘online’, function () {
var toastTop = app.toast.create({
text: ‘Awesome, We Are BACK ONLINE!’ ,
position: ‘top’,
closeTimeout: 3000


view.router.back(view.router.previousRoute.url, {
ignoreCache: true,
preload: true,
force: true

$$(document).on(‘offline’, function () {
var toastTop = app.toast.create({
text: 'Ooops, Seems We Lost A Reliable INTERNET CONNECTION, Let’s Try Re-connecting… ',
position: ‘top’,
closeTimeout: 3000


app.router.navigate(’/no-network/’); //To NO NETWORK PAGE


i have also tried… app.router.back(), view.router.back() but I keep getting his error in the console…app.js:59 Uncaught ReferenceError: view is not defined at HTMLDocument.<anonymous> (app.js:59) at HTMLDocument.l (framework7.min.js:12) at Object.fireDocumentEvent (cordova.js:233) at network.js:73 at Object.callbackFromNative (cordova.js:291) at Object.callbackSuccess (cordova.js:271) at onSuccess (cordova.js:969) at network.js:43

Any remedies?

Error message is self explaining, you don’t have view variable in the place you write this code. You can use app.views.main instead to reference main view

1 Like

Thanks alot Mr. @nolimits4web, will try this today… and revert… Thanks alot for your time…and everything!

Mr. Vlad… How exactly to i use this? Like app.views.main.router.back()? I am in my code but I cant seem to get it really well…

Then would be good to see live example, there is something wrong in your code

Thanks @nolimits4web,
Below I detech the event online
$$(document).on('online', function () { var toastTop = app.toast.create({ text: 'Awesome, We Are ONLINE!' , position: 'top', closeTimeout: 4000 }); toastTop.open(); //WANNA REDIRECT THE USER BACK TO THE PAGE THEY ON HERE**** });

Here is how I redirect them on offline

$$(document).on('offline', function () { var toastTop = app.toast.create({ text: 'Ooops, Seems We Lost A Reliable INTERNET CONNECTION, Let\'s Try Re-connecting... ', position: 'top', closeTimeout: 5000 }); toastTop.open(); app.router.navigate('/no-network/'); //To NO NETWORK PAGE });

I want to simply take them beack to where they were before…

Here Is my no-network-page… (On offline, It detects very well and actually navigates to that page…)

  `<div class="page" data-name="no-network">
    <!-- Top Navbar -->
      <div class="navbar">
      <div class="navbar-inner sliding">
        <div class="title center"><strong>Connection Lost</strong></div>
    <!-- Scrollable page content-->
      <div class="page-content" >
        <div class="card">
          <div class="card-content">
                <div class="block-title">TRYING TO CONNECT AGAIN</div>
                <div class="block block-strong">
                        <span class="progressbar-infinite color-multi"></span>

I keep getting errors in my console… In the rest of the app, I use async routing as I have to connect to my MySQL DB online… So I keep making requests and resolving or rejecting…

Thanks alot…