How to reload current page from Offline to Online?

Hi,

My application only work with online so if user logged in with network and turn off i need to show offline message and again if user turned on network i need to reload current page. Please suggest how to achieve this functionality on framework 7 v2.

Dom7(window).on('online',function(e){
  console.log('online');
});
Dom7(window).on('offline',function(e){
  console.log('offline');
});

Thanks @plpl,

Its helps to detect network status only, after this i need to reload current page?

Dom7(window).on('online',function(e){
  app.view.current.router.refreshPage();
});

http://framework7.io/kitchen-sink/
console:

Dom7(window).on('online',function(e){
  app.view.current.router.refreshPage();
});
app.view.current.router.navigate('/accordion/');
app.view.current.router.once('pageInit',function(page){
  var el=page.$pageEl.find('.accordion-item')[0];
  setTimeout(function(){
    app.accordion.open(el);
  },1000);
  setTimeout(function(){
    Dom7(window).trigger('online');
  },2000);
});

thats the code i use for detecting online/offline status

function updateIndicator() {
	if(navigator.onLine){
		offlinePopup.close();
		app.view.current.router.refreshPage();
	} else {
		offlinePopup.open();
	}
}

// Update the online status icon based on connectivity
window.addEventListener('online',  updateIndicator);
window.addEventListener('offline', updateIndicator);
1 Like