Navigation

    Monaca & Onsen UI
    • Register
    • Login
    • Search
    • Tags
    • Users
    • Blog
    • Playground
    1. Home
    2. username1
    U
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    username1

    @username1

    0
    Reputation
    4
    Posts
    844
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    username1 Follow

    Posts made by username1

    • RE: [SOLVED] How do I have more than 1 workable button?

      SOLVED, but I’ll keep this up for any other people who might happen to come across a similar issue. :)

      Solution: I changed the second ‘else if’ statement to an ‘if’ statement. So:

      else if (page.id === ‘page1’) {
      page.querySelector(’#push-button-page3’).onclick = function() {
      document.querySelector(’#myNavigator’).pushPage(‘page3.html’, {data: {title: ‘Page 3’}});

      changed to:

      if (page.id === ‘page1’) {
      page.querySelector(’#push-button-page3’).onclick = function() {
      document.querySelector(’#myNavigator’).pushPage(‘page3.html’, {data: {title: ‘Page 3’}});


      Original:

      Thank you for the response. For some reason I’m not making the connection using the tutorial. I’ll give it more of a go. Here’s the code I tried making that didn’t work. Going to page 2 works, but when I click page 3 it doesn’t go anywhere.

      <!DOCTYPE html>
      <html>
      <head>
      <link rel=“stylesheet” href="./css/onsenui.css">
      <link rel=“stylesheet” href="./css/onsen-css-components.min.css">
      <script src="./js/onsenui.min.js"></script>
      <script>
      document.addEventListener(‘init’, function(event) {
      var page = event.target;

      if (page.id === ‘page1’) {
      page.querySelector(’#push-button’).onclick = function() {
      document.querySelector(’#myNavigator’).pushPage(‘page2.html’, {data: {title: ‘Page 2’}});
      };
      } else if (page.id === ‘page1’) {
      page.querySelector(’#push-button-page3’).onclick = function() {
      document.querySelector(’#myNavigator’).pushPage(‘page3.html’, {data: {title: ‘Page 3’}});
      }} else if (page.id === ‘page2’) {
      page.querySelector(‘ons-toolbar .center’).innerHTML = page.data.title;
      } else if (page.id === ‘page3’) {
      page.querySelector(‘ons-toolbar .center’).innerHTML = page.data.title;
      } });
      </script>
      </head>
      <body>
      <ons-navigator swipeable id=“myNavigator” page=“page1.html”></ons-navigator>

      <template id="page1.html">
        <ons-page id="page1">
          <ons-toolbar>
            <div class="center">Page 1</div>
          </ons-toolbar>
      
          <p>This is the first page.</p>
      
          <ons-button id="push-button">Page 2</ons-button>
          <ons-button id="push-button-page3">Page 3</ons-button>
        </ons-page>
      </template>
      
      <template id="page2.html">
        <ons-page id="page2">
          <ons-toolbar>
            <div class="left"><ons-back-button>Page 1</ons-back-button></div>
            <div class="center"></div>
          </ons-toolbar>
      
          <p>This is the second page.</p>
        </ons-page>
      </template>
      <template id="page3.html">
          <ons-page id="page3">
            <ons-toolbar>
              <div class="left"><ons-back-button>Page 1</ons-back-button></div>
              <div class="center"></div>
            </ons-toolbar>
        
            <p>This is the third page.</p>
          </ons-page>
        </template>
      

      </body>
      </html>

      posted in Onsen UI
      U
      username1
    • [SOLVED] How do I have more than 1 workable button?

      Sorry this is totally a newbie question. If I use the navigator style navigation, how do I get 2 buttons to go to different pages. Then how do I get 2 more buttons in each of those options to go to different pages? I got one button working.

      Let’s say I want to make an app showing recipes. The home page will have breakfast and lunch, then each of those pages will have 2 recipes each that I can click to view the full recipe. How would I do that navigation?

      I have a feeling that if I see the solution I’m going to be like, “Wow how the heck did I miss that.” I have BASIC HTML/ CSS/ Javascript knowledge, but for some reason this isn’t clicking for me.

      posted in Onsen UI
      U
      username1