Search code examples
javascriptjquery-mobileibm-mobilefirst

Swipe left is getting fired after two gestures


I am using Worklight 6.2.

I have written following jQuery mobile code to open a panel:

$(document).ready(
        function() {    
             $("div[data-role='page']").on("swipeleft", function(){
             openPanel();
        });

function openPanel(){
    $('#navpanel').panel("open");
}

However, the panel is getting opened only when I swipe left twice. I have written this code in index.html file in document.ready() block.


Solution

  • Works fine for me by following the below.
    That is, only 1 swipe is required to display the panel.

    1. Created a new Worklight project and application with jQuery Mobile 1.4.4 (by following the wizard)
    2. Changed the BODY in common\index.html to:

      App header Click to open panel, or swipe to the left...
      <div data-role="panel" id="mypanel" data-display="push">
          my panel
      </div>
      
    3. Changed common\js\main.js to:

      function wlCommonInit(){
          $("div[data-role='page']").on("swipeleft", function(){
              openPanel();
          });
      }
      
      function openPanel(){
          $('#mypanel').panel("open");
      }
      

    Tested on iPhone 5s + iOS8.