The NavigatorView in Onsen UI has an empty page stack, returning back to the main page

Hello, I am new to the Onsen UI Framework and I must say it is a very nice and beautiful framework. However, I am facing an issue with navigation. When transitioning from the main page to another template, where I input some data and save it, I encounter an error when trying to go back to the main page using myNavigator.popPage(). The error message states "NavigatorView's page stack is empty". Below is the code snippet I am currently using with a sliding menu:

Index.html


    <ons-navigator title="Navigator" var="myNavigator">
          <ons-sliding-menu close-on-tap
                          main-page="main.html"
                          menu-page="menu.html"       
                          side="left"
                          max-slide-distance="250px"
                          var="menu">
        </ons-sliding-menu>
  </ons-navigator>


 <ons-template id="menu.html">      
  <ons-list>
    <ons-list-item modifier="chevron" onclick="menu.setMainPage('nomor.html', {closeMenu: true})">
      Setting Nomor
    </ons-list-item>
  </ons-list>
</ons-template>


<ons-template id="nomor.html">
    <ons-page ng-controller="penomoranController">
    <ons-toolbar>
      <div class="left">
        <ons-toolbar-button ng-click="menu.toggleMenu()"><ons-icon icon="ion-navicon" style="font-size: 32px; width: 1em;"></ons-icon></ons-toolbar-button> 
    </div>
      <div class="center"> Setting Nomor</div>

      <div class="right">
        <div id="prosesAjax"></div>
      </div>

    </ons-toolbar>

        <ons-list>
            <ons-list-item>
                <input type="text" placeholder="nomor" ng-model="noini"  class="text-input text-input--transparent" style="margin-top:8px; width: 100%;">
            </ons-list-item>
        </ons-list>

        <div class="content-padded">
        <ons-button id="btnSignIn" modifier="large"  ng-click="saveData()">
          Save
        </ons-button>
      </div>
  </ons-page>
</ons-template>

AngularJS Controller

agendaApp.controller('penomoranController',function ($scope){
                 $scope.saveData=function(){
                            $scope.myNavigator.popPage();
                 };


     }); 

Whenever I click the Save Button, I receive the error message 'NavigatorView's page stack is empty'. Can someone please help me identify what is causing this issue? Thank you for your assistance.

Answer №1

When using menu.setMainPage, a new stack is created. In your specific case, only one page (nomor.html) exists in the myNavigator stack. Therefore, when attempting to popPage, there are no other pages to navigate back to.

To solve this issue, consider utilizing myNavigator.pushPage(nomor.html) instead. By doing so, the nomor.html page will be pushed onto the myNavigator stack, allowing you to then successfully use popPage.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery ajax not working after initial click

I have implemented a link that uses the Instagram API to fetch and display images. My goal is to have this link refresh when clicked again, showing newer images or leading to multiple links. However, I am facing issues as it always fails after the initial ...

In the year 2021, eliminate linked documents using mongoose/MongoDB middleware

After extensive research on stack overflow, I attempted various solutions for deleting referenced documents in MongoDB using node.js. Unfortunately, most of them either utilize deprecated methods or simply do not function as expected. Within my applicatio ...

Is it possible to switch between JavaScript tabs using a button?

I am currently working on a website project where I'm using JavaScript to implement tabs. I want to create a button that can navigate to the next tab. Whether I have to hardcode the tab IDs into the script or not, I just need a way to progress through ...

What happens to CSS specificity when JavaScript is used to change CSS styles?

When JavaScript modifies CSS, what is the specificity of the applied styles? For example: document.getElementById("demo").style.color = "red"; Would this be deemed as inline styling? ...

What is the best location in an Angular application to store "shared" data?

In continuation of my previous question about the best practice for an Angular directive requesting data, I am now seeking guidance on where to store application data. Specifically, information regarding the current user's name and roles within the ap ...

"Exploring the Backbone collection object in our browser's developer console

When I log one of my Backbone collections, the object summary shows that the length is 0 and the models array is empty. However, in the dropdown detail, it displays the correct length and model array. When I run console.log(this.collection.models), it re ...

The jquery UI button is displaying too wide even though the padding is set to zero

My goal is to decrease the width of certain jQuery buttons. Though I have attempted to eliminate padding using the code below, there remains a minimum of 5 pixels on either side of the text within my button. .button().css({ 'padding-left':' ...

Javascript cards arranged in descending order

I'm in the process of developing a sorting feature that arranges cards in the DOM from Z to A with the click of a button. Although I've successfully implemented the logic for sorting the array, I'm facing difficulties in rendering it. Withi ...

Combining and arranging numerous items in a precise location in three.js

I am currently working on a web application using three.js with Angular and facing some challenges when trying to set the precise positions of objects. The requirement is to load various objects and position them in specific locations. In order to load di ...

Encountering a situation where an empty object is received while attempting to send a

While using Postman to make a request to the API I created for Social Media Application that involves following and followers functionality, I noticed that I am receiving an empty object: {}. However, upon inspection, everything seems to be correct on my e ...

Set the default value in the second dropdown menu according to the choice made in the first dropdown menu

Hey there! I'm trying to dynamically load information based on the default value in the first dropdown hikashop_product_characteristic_1. Depending on the default value selected in this dropdown, I want to show/hide specific options in the second drop ...

How to set the value of an `<input type="date"` in jQuery

Having trouble figuring out why this code isn't functioning properly. The input field I'm using is a simple 'input type="date"' setup like this.... <input type="date" name="Date"/> I am attempting to have the value automatically ...

"Encountering a form submission error - requested resource not located

I am currently trying to submit a form to an MVC controller using AJAX, where the controller is expected to take a form collection. I came across this helpful resource on Stack Overflow regarding passing formcollection using ajax call to an action. However ...

Tips for inserting an element into a div only if both the element and div share the same id using JavaScript

Looking to drag and drop an element into a div with multiple divs, but only allowing the drop if the IDs of the element and the div match. Trying to retrieve the ID of the div where the image is being dragged, compare it with the ID of the dragged image, a ...

Ways to incorporate additional CSS after an image has been uploaded

I'm having an issue with the text box not completely staying inside the gray area when I upload an image. Is there a way to automatically expand the gray area where the text box is located when an image is uploaded? Thank you! Check out the code on J ...

Upon mounting, the componentDidMount function and XMLHttpRequest retrieved data redundantly due to an invalid JSON format

I'm currently utilizing a basic express static server to efficiently manage my static files. app.use(express.static(path.join(__dirname, 'public'))); Presented below is the webpack.config.js file const webpack = require('webpack&apos ...

javascript with a focus on objects

Having trouble with the scene.add(Obj); line for my object player1. I keep getting an error saying that Obj does not exist: function Player(x, y, z) { this.Speed = 0; this.AngleAcc = 0; this.Angle = 0; this.X=x; this.Y=y; this.Z=z; this.MaxSpeed = ...

What are the steps to reset a tooltip with varying options based on the size of the screen?

Currently, I am utilizing the tooltipster.js library to create tooltips and attempting to adjust the default distance of the tooltip based on various screen sizes. Initially, the initialization appears as follows: $(inputTooltipTrigger).tooltipster({ ...

Halt period indicated in the document specifying the designated timeframe

If I have two files named index.php and fetch.php The contents of index.php are as follows: <script> $(document).ready(function(){ setInterval(function(){ $('#fetch').load('fetch.php') }, 1000); }); </sc ...

Placing a div tag directly beneath another div tag

Imagine you have a div element with the class name divstudent, let's call this one div1. Now, you want to dynamically create another div element below div1, but outside of it using JavaScript. How can you achieve this? "div1" <div class="divstuden ...