I'm having problem with window.history.back()
because it's returning only one page.
I use the following function:
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown() {
if($('.upage:visible').attr("id") == 'listar_CELULAS'){
var r=confirm("Você realmente deseja sair do aplicativo ?");
if(r==true){
navigator.app.exitApp();
}else{
}
}else{
console.log("ta entrando aqui");
window.history.back();
}
}
</script>
I need all to return to the starting point of the stack. To put in the history
stack I use this function:
function activate_page(sel, have_state)
{
var $dn = $(sel);
var is_vis = $dn.is(":visible");
if(!is_vis)
{
$dn.parents("body").find(".upage").addClass("hidden");
$dn.removeClass("hidden");
window.history.pushState({upage:sel}, sel, document.location.origin + document.location.pathname +sel);
$(document).trigger("pagechange");
}
}
Probably the ionic is part in this problem, in fact not to rightly understanding the moment that everyone is doing something, follow my ionic code:
angular.module('ionic')
.run(function($ionicPlatform,$ionicPopup, $state,$ionicHistory){
$ionicPlatform.registerBackButtonAction(function (event) {
//console.log(window.history);
if($state.current.name=="app.listar_CELULAS"){
alert("entro aqui");
navigator.app.exitApp();
}
else {
//window.history.back();
}
}, 100);
});
Here is the function that theoretically populate the history of visited pages:
function activate_page(sel, have_state)
{
var $dn = $(sel);
var is_vis = $dn.is(":visible");
if(!is_vis)
{
$dn.parents("body").find(".upage").addClass("hidden");
$dn.removeClass("hidden");
window.history.pushState({upage:sel}, sel, document.location.origin + document.location.pathname +sel);
console.log(window.history);
$(document).trigger("pagechange");
}
}
Where is the error?
Thanks for the time being.