-1

I am using fullPage.js. It's working on desktop as expected no issue, but if I run same code on iPad it is not working and on android device it sometimes work and sometimes not. I am doing a website in which click on active pagination text it opens a div.

in jquery.fullpage.js

var li = '<li><a href="#' + link + '" onclick="displayDetails('+i+');"><span>' + tooltip + '</span></a>';

function :

function displayDetails(id) {

    if($('#part').hasClass('active'))
    {
        $("#btn").trigger('click');

    }
}
$('#btn').click(function () {
    //some piece of code
    //to open an div
}

Html code:

<div id="fullpage">
    <section class="section" id="part0">
      <div id="section0"></div>
    </section>
    <section class="section" id="part1">
      <div id="section1"></div>
    </section>
 </div>

This code works perfectly on desktop. I am really not getting why it is not working on iPad and android devices.

Apb
  • 979
  • 1
  • 8
  • 25

3 Answers3

0

Use touchstart.

function displayDetails(id) { 
    if($('#part').hasClass('active'))
    {
       $("#btn").trigger('click', 'touchstart');
    }
}

$(document).on('click touchstart', '#btn', function() {
    //some piece of code
    //to open an div
});

Demo: http://jsfiddle.net/kxw4vv0q/

RGS
  • 5,131
  • 6
  • 37
  • 65
0
function displayDetails(id) { 
    if($('#part').hasClass('active'))
    {
       $("#btn").trigger('click', **'touchend'**);
    } }

$(document).on('click touchstart', '#btn', function() {
    //some piece of code
    //to open an div });
Alvaro
  • 40,778
  • 30
  • 164
  • 336
Lalji Tadhani
  • 14,041
  • 3
  • 23
  • 40
0

The answer provided by @RGS is correct, but you have also to remove the inline javascript you are using here:

onclick="displayDetails('+i+');"

Just remove that line and add the i as a data attribute of the list element. Then you can obtain it inside the event

$(document).on('click touchstart', '#btn', function() {

Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • I need that data element. I can't remove it. @RGS answer is partially correct for me. it made my website working on android device – Apb Feb 27 '15 at 12:40
  • What I'm saying is, you dont need to pass it in your function. You don't need the `onclick='...'`. Just add it in a `data` attribute and get it in the event... – Alvaro Feb 27 '15 at 17:02