Isma
Isma

Reputation: 67

Hammers.js and table touch events

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.

Upvotes: 2

Views: 277

Answers (1)

Ludus H
Ludus H

Reputation: 239

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.

Upvotes: 1

Related Questions