2

I have an idea to make some web page suitable for touch devices, and there I have a table with rows and columns. I planned to click on some cell and produce call to different pages or functions. I need support of tap, doubletap and taphold table events and after long play with jQuery and jQm I gave up as taphold isn't right recognized, rather like tap. Due that I decided to take help of hammer.js but I wasn't able to force this plug in to wotk with table TD cells, just with DIV,

etc. I need for example to doubletap on some TD, read tapped cell (contents, ID, column and row info) but no score. How to solve this? Is it possible like:

        var myElement0 = document.getElementById('tbl_hours td');
        // create a simple instance
        // by default, it only adds horizontal recognizers
        var mc0 = new Hammer(myElement0);
        // listen to events...
        mc1.on("panleft panright tap press doubletap", function(ev) {
            myElement0.textContent = ev.type +" gesture is detected.";
        });

ID of table is tbl_hours, but no TD cell has its own ID. Thank you.

0

1 Answer 1

1

I don't have complete answer for you but here is solution for TAP I found;

var tab = document.getElementById("tbl_hours"); // reference to table
Hammer(tab).on('tap',function(ev){ 
ev.target.style.background='red'; //will give red background for the held cell
});

On same way I tried doubletap but doesn't work.

3
  • Thank you, I would like to see a solutions for other events: doubletap and press & hold. Anybody, please?
    – Isma
    Commented Jul 22, 2017 at 16:55
  • 1
    doubletap is harder, here is a discussion (+ code) about that topic: github.com/mckamey/doubleTap.js/blob/master/README.md
    – deblocker
    Commented Jul 28, 2017 at 6:55
  • @deblocker: thanks mate, I'll try to implement suggested solution. I hope it will work for me.
    – Ludus H
    Commented Jul 28, 2017 at 14:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.