The integration of Onsen UI 2.0 Splitter with pushPage function experiences compatibility issues

I have created a main tab called tab1.html with a menu for changing options or accessing settings. Now, I want to add a button on tab1.html that takes you to another tab, tab4.html. However, I am facing an issue where both the menu (splitter) and pushpage function do not work together. How can I solve this problem?

<ons-splitter>
<ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>
<ons-page>
  <ons-list>
    <ons-list-item onclick="fn.load('tab1.html')" tappable>
      <ons-icon icon="home" style="color: #1e88e5;"></ons-icon><p  style="opacity: 0.6;">   Startseite</p>
    </ons-list-item>
    <ons-list-item onclick="fn.load('tab6.html')" tappable>
      <ons-icon icon="user" style="color: #1e88e5;"></ons-icon><p style="opacity: 0.6;">   Mein Profil</p>
    </ons-list-item>
    <ons-list-item onclick="fn.load('tab8.html')" tappable>
      <ons-icon icon="sliders" style="color: #1e88e5;"></ons-icon><p style="opacity: 0.6;">   Einstellungen</p>
    </ons-list-item>
  </ons-list>
</ons-page>
</ons-splitter-side>
<ons-splitter-content id="content" page="tab1.html"></ons-splitter-content>
</ons-splitter>

And here is the navigator setup for transitioning to page 4:

<ons-navigator id="pushpage_navigator" page="tab1.html"></ons-navigator>

Next, let's take a look at tab1.html:

<ons-template id="tab1.html">
<ons-page> 
<div class="left"> <!--left-->
  <ons-toolbar-button onclick="fn.open()">
    <ons-icon icon="md-menu"></ons-icon>
  </ons-toolbar-button>
</div>
<button onclick="change()" />
</ons-page>

Moving on to tab4.html, which will be accessed from tab1.html:

<ons-template id="tab4.html">
<ons-page>
<ons-toolbar>
  <div class="left"><ons-back-button>Back</ons-back-button></div>
  <div class="center">Clock View</div>
 </ons-toolbar>
 </ons-page>
 </ons-template>

Lastly, we have the JavaScript functions defined:

//ONSEN UI 2.0
window.fn = {};

window.fn.open = function() {
  var menu = document.getElementById('menu');
  menu.open();
};

window.fn.load = function(page) {
  var content = document.getElementById('content');
  var menu = document.getElementById('menu');
  content.load(page)
 .then(menu.close.bind(menu));
};

function change()
{
  var myNavigator = document.getElementById('pushpage_navigator');
  myNavigator.pushPage('tab4.html');
}

The issue arises when placing the 'ons-navigator' tag before the splitter, causing it to malfunction. On the other hand, placing it after the splitter leads to errors like 'myNavigator is null' or 'pushPage is already running'.

Answer №1

It seems that there may be an issue with how the splitter and navigator elements are nested. Both of these elements should serve as containers for actual pages, so in order to use both, one should be placed inside the other.

For example:

<ons-navigator id="pushpage_navigator">
  <ons-page>
    <ons-splitter>
      <ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>
        <ons-page>
          <ons-list>
            <ons-list-item onclick="fn.load('tab1.html')" tappable>1</ons-list-item>
            <ons-list-item onclick="fn.load('tab6.html')" tappable>6</ons-list-item>
            <ons-list-item onclick="fn.load('tab8.html')" tappable>8</ons-list-item>
          </ons-list>
        </ons-page>
      </ons-splitter-side>
      <ons-splitter-content id="content" page="tab1.html"></ons-splitter-content>
    </ons-splitter>
  </ons-page>
</ons-navigator>

This configuration will allow access to both the splitter and navigator from the start. You can view a demo here.

If I have misunderstood your issue or if you encounter further difficulties, please feel free to leave a comment so I can update my response accordingly.

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

Having issues with AJAX and button submit while trying to upload a file using Flask

I've been attempting to incorporate a file upload feature (specifically a .csv file) using bootstrap, and then submit it by clicking on a button. I've experimented with various methods to implement the file upload functionality, but haven't ...

The fade-in effect will initiate from the start once the mouse leaves the element (with a

Currently, I am in search of a solution for improving the navigation menu I am developing. By clicking on this JSFiddle link, you can view the code in action. The issue I am facing is that the fadeIn effect should only occur when hovering over the nav-ite ...

Programmatically setting a value in MUI Tree Select

Hey there, I've been using this package and everything is working smoothly. However, I'm having trouble programmatically selecting a value that the user has already chosen using the same component. Check it out on CodeSandbox The developer reco ...

Using the section :export in the SCSS :root declaration

In the file test.module.scss, I store all my variables for colors, typography, and more. I want to be able to use these variables in my react components. However, the file starts with :root to define the variables: :root{ --color-white: #fff; --color-b ...

Filtering an array by a search term

How do you filter an array based on a specific search term? For example, if we have an array [Tom Harry, Tom John, John Glen, Tom Harward] and we search for "Tom H," then only Tom Harry and Tom Harward should be the output. [Tom Harward, Tom Harry]; Usin ...

Removing a MongoDB record when a URL is accessed using node.js

Currently, I am developing a Twitter replica for a project using node.js and express. Tweets are being stored in MongoDB. One of the functionalities I am working on is allowing users to delete their tweets. The idea is to have a button or link under each ...

Limiting multiple checkbox inputs in a React application can be easily achieved by utilizing React

Trying to create a form where the user can only check three boxes and uncheck them. The decrement on setCurrentData(currentData - 1) is not working as expected. Even after deselecting, the currentData remains at 3, preventing the user from checking any mo ...

Exploring logfile usage in JavaScript. What is the best way to structure the log?

Currently, I am developing a Python program that parses a file and records the changes made to it. However, I am facing a dilemma regarding the format in which this information should be saved for easy usage with JavaScript on the local machine. My objecti ...

animation glitches in safari and chrome when using jquery

Hey there! I'm currently working on a form with multiple steps, where I animate the step number for each level of registration. The animation functions perfectly in Firefox, but unfortunately, it's not supported in Chrome and Safari due to an iss ...

Unable to send data to Spring Controller from form submission

As a newcomer to Spring, I have been exploring tutorials online to enhance my knowledge. Recently, I developed a straightforward Spring MVC Login App utilizing AngularJS for the frontend and JSON for data posting to the Spring Controller. The login form I ...

Trigger the datepicker's onselect event programmatically

Does anyone know how to manually trigger the onselect event of a datepicker? My code is currently functioning correctly (retrieving data from a database based on the value of the datepicker's altfield), but I'm having an issue where the onselect ...

Issue with electron-vue: Unable to modify Vuex state when using RxJS subscribe

I need help with my code involving two functions in the mutations and two pieces of state const state = { files: [], uploadProgress: 0 } const mutations = { SET_UPLOAD_IMAGE: (state, files) => { state.files = files }, UPLOAD_IMAGE: ( ...

What is the best way for Selenium Java to handle AngularJS version 1.6's wait time?

I have searched through various threads on this topic, but none of the solutions I have come across have worked for AngularJS v1.6 Here is what I have attempted: public void waitForAngularRequestsToFinish() { while ((boolean) jsExec.executeScript( ...

What is the best way to retrieve all string constants from HTML or JSX code?

UPDATE: I recently developed my own babel plugin CLI tool named i18nize-react :D I am currently in the process of translating an existing react application from English to another language. The string constants in the JSX are all hardcoded. Is there a sim ...

What is the best way to upload images in Vue.js without using base64 formatting?

Is there a way to upload an image file without it being base64 encoded? I currently can only achieve base64 format when trying to upload an image. How can I modify the code to allow for regular file uploads? <script> submitBox = new Vue({ el: "#su ...

How do I navigate back to show the initial parent component instead of the nested child component in ReactJS?

The data flow in my React app goes like this: SubmitForm -parent-> Results -parent-> Presentation -parent-> ButtonBackToSearch I am delving into ReactJS and trying to adopt the right mindset for creating single-page applications. Currently, I am ...

Exploring the intricacies of password reset functionality in Node.js and Angular

I am currently exploring the implementation of password reset and forgot password features using AngularJS (1.x) with Nodejs as the backend. After coming across this informative article on Nodejs backend setup, I stumbled upon a relevant discussion on Angu ...

Guide on adding a new item to a JSON file in a ReactJS client side and NodeJS Express server side setup

Still learning the ropes with NodeJS and Express, but I'm curious to know if it's possible to add new objects after loading the API via the client-side. Essentially, I'd like to first load the API on the server-side, which contains the exist ...

Modifying the color of a header through clicking on a specific anchor link

My goal is to create a fixed side nav bar on my webpage with an unordered list that links down the page using anchors. In addition, I want to dynamically change the color of an h2 element based on which item in the fixed nav bar is clicked on. For instan ...

HtmlButton failing to execute client-side validation on IE11

I am encountering a strange problem with a web form using the HTMLButton in an asp.net environment. Due to formatting requirements, I need to utilize a <button> construct which functions properly in all browsers except for IE11. <button id="cmdLo ...