locked
Manually changing FlipView currentpage works...but only once or twice. (edit: button eventlistener issue) RRS feed

  • Question

  • HTML Snippet
     
            <div class="category-submenu">
              <ul>
                <li onclick="categoryNS.FlipToFrame1();">all</li>
                <li onclick="categoryNS.FlipToFrame2();">hightest rated</li>
                <li onclick="categoryNS.FlipToFrame3();">most downloaded</li>
                <li onclick="categoryNS.FlipToFrame4();">newest</li>
              </ul>
            </div>
    
            <div id="CategoryFlipView" class="main-category-flipview" data-win-control="WinJS.UI.FlipView">
              <div style="width:100%;height:100%;background-color:#EEEEEE;">
                <p>CONTENTS - ALL</p>
              </div>
              <div style="width:100%;height:100%;background-color:#DDDDDD;">
                <p>CONTENTS - HIGHEST RATED</p>
              </div>
              <div style="width:100%;height:100%;background-color:#CCCCCC;">
                <p>CONTENTS - MOST DOWNLOADED</p>
              </div>
              <div style="width:100%;height:100%;background-color:#BBBBBB;">
                <p>CONTENTS - NEWEST</p>
              </div>
            </div>
    
     
    JavaScript Nippet
     
      function fragmentLoad(elements, options) {
        WinJS.UI.processAll(elements)
                .then(function () {
          //  TODO:
    
          WinJS.Namespace.define('categoryNS', {
            FlipToFrame1: FlipToFrame1,
            FlipToFrame2: FlipToFrame2,
            FlipToFrame3: FlipToFrame3,
            FlipToFrame4: FlipToFrame4
          });
        });
      }
    
      function FlipToFrame1() {
        var theFlipView = WinJS.UI.getControl(document.getElementById("CategoryFlipView"));
        if (theFlipView.currentPage != 0) { theFlipView.currentPage = 0; }
      }
    
      function FlipToFrame2() {
        var theFlipView = WinJS.UI.getControl(document.getElementById("CategoryFlipView"));
        if (theFlipView.currentPage != 1) { theFlipView.currentPage = 1; }
      }
    
      function FlipToFrame3() {
        var theFlipView = WinJS.UI.getControl(document.getElementById("CategoryFlipView"));
        if (theFlipView.currentPage != 2) { theFlipView.currentPage = 2; }
      }
    
      function FlipToFrame4() {
        var theFlipView = WinJS.UI.getControl(document.getElementById("CategoryFlipView"));
        if (theFlipView.currentPage != 3) { theFlipView.currentPage = 3; }
      }
    

    Now those list items clicking to change the FlipView works, but only once or twice and/or never. It's quote sporadic on the clicking working.
     

    • Edited by Harlequin Tuesday, January 31, 2012 10:11 PM Title change
    Tuesday, January 31, 2012 8:53 PM

Answers

  • Got this working. Had to add eventlisteners in the Javascript for the button clicks to work.

    I'm now under the impression that adding events in the HTML is buggered in the current version. Anyone else find this?

    • Marked as answer by Harlequin Tuesday, January 31, 2012 10:10 PM
    Tuesday, January 31, 2012 9:44 PM