2016년 12월 2일 금요일

Clicking or touching table cell for editing


My objective is to make a table (3 columns x n rows) in which each cell is pickable for editing of text. The table code is HTML/JavaScript which is called from AI2 code when the screen initializes. Everything (including clicking and editing a cell) works with an implementation adapted for testing on my Win7 laptop. Everything except the cell touch for editing also works fine on my Android phone. I cannot get the app to respond to a touch from a listener (again, this does work on my laptop). To test, I included an alert() in my listener code but it never fires.

I have seen a lot of comments about click and/or touchend not being implemented or not working on Android. Does anyone know if what I am trying to do can be done in Android?

My listener code is:

// listen for a click
//listTable.addEventListener('click', function(ev){
// listen for a tap
listTable.addEventListener('touchend', function(ev){
    // get the event targets ID
ev.preventDefault()
    clickedTr = ev.target.parentNode.rowIndex;
    clickedTd = ev.target.cellIndex;
    selectedCell = listTable.rows[clickedTr].cells[clickedTd];
    selectedCell.setAttribute('bgColor', '#D3D3D3'); //LightGray, White is #FFFFFF
selectedCell.focus();
    if(priorClickedTd != undefined) {
         listTable.rows[priorClickedTr].cells[priorClickedTd].setAttribute('bgColor', '#FFFFFF');
    }
    priorClickedTr = clickedTr;
    priorClickedTd = clickedTd;
    selectedCell.setAttribute('contentEditable', 'true');
alert('cell tapped');
    },false);
// End listen for a click

-- 
Does anyone know if what I am trying to do can be done in Android?

I don't know...

but sometimes it's easier to use libraries...
I used the jEditable.js library  in my Editable example, see also my working example here https://puravidaapps.com/editable.php

-- 
Thanks 

-- 

댓글 없음:

댓글 쓰기