默认后退按钮任务没有发生

时间:2014-03-24 17:27:13

标签: cordova chocolatechip-ui

我有一个简单的代码,我使用Phonegap / Apache Cordova和巧克力芯片UI。 我打电话给祖父和父亲的父亲 所以就像爷爷一样 - >父亲 - >儿子 一切正常。但后退按钮有问题。我不能从父亲到祖父或(从儿子到父亲)回来。任何想法?

代码

 <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="mobile-web-app-capable" content="yes">
      <meta name="msapplication-tap-highlight" content="no">
      <title>ChocolateChip-UI Android</title>
      <link rel="stylesheet" href="chui/chui-ios-3.5.2.min.css">
      <script src="chui/jquery-2.1.0.min.js"></script>
      <script src="chui/chui-3.5.2.min.js"></script>
      <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

      <script>
        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady(){}
        $(function() {

        });
      </script>
    </head>
    <body>
      <nav class="current">
        <h1>Family Tree</h1>
      </nav>
      <article id="main" class="current">
        <section>
          <ul class='list' role='list'>
            <li class='comp' data-goto="grandfather">
              <div>
                <h3>Grandfather</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
              </ul>
        </section>
      </article>

      <nav class='next'>
        <a href='#' class='button back'>Navigation</a>
        <h1>Family Tree</h1>
      </nav>
      <article id="grandfather" class='next'>
        <section>
          <ul class='list' role='list'>
            <li class='comp' data-goto="Father1">
              <div>
                <h3>Father1</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
             <li class='comp' data-goto="Father2">
              <div>
                <h3>Father2</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
             <li class='comp' data-goto="Father3">
              <div>
                <h3>Father3</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
              </ul>
        </section>
      </article>

       <nav class='next'>
        <a href='#' class='button back'>Navigation</a>
        <h1>Family Tree</h1>
      </nav>
      <article id="Father1" class='next'>
        <section>
          <ul class='list' role='list'>
            <li class='comp' data-goto="main">
              <div>
                <h3>Son1</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
             <li class='comp' data-goto="main">
              <div>
                <h3>Son2</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
             <li class='comp' data-goto="main">
              <div>
                <h3>Son3</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
              </ul>
        </section>
      </article>

      <nav class='next'>
        <a href='#' class='button back'>Navigation</a>
        <h1>Family Tree</h1>
      </nav>
      <article id="Father2" class='next'>
        <section>
          <ul class='list' role='list'>
            <li class='comp' data-goto="main">
              <div>
                <h3>Son4</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
             <li class='comp' data-goto="main">
              <div>
                <h3>Son5</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
              </ul>
        </section>
      </article>

      <nav class='next'>
        <a href='#' class='button back'>Navigation</a>
        <h1>Family Tree</h1>
      </nav>
      <article id="Father3" class='next'>
        <section>
          <ul class='list' role='list'>
            <li class='comp' data-goto="main">
              <div>
                <h3>Son6</h3>
              </div>
              <aside>
                <span class='nav'></span>
              </aside>
            </li>
              </ul>
        </section>
      </article>

      </body>
      </html>

1 个答案:

答案 0 :(得分:0)

您的后退按钮不需要href,它会干扰内置导航。 Chui.js负责幕后导航。看一下按下后退按钮的事件处理程序。

/////////////////////////// // Initialize Back Buttons: /////////////////////////// $('body').on('singletap', 'a.back', function() { if (this.classList.contains('back')) { $.UIGoBack(); } });

documentation了解如何在导航栏中添加后退按钮

<nav class='current'> <a class='button back'>Back</a> <h1>Candies</h1> </nav>