以下是我的代码。双击事件没有被 jeditable 捕获和执行。
javascript:
$(document).ready(function(){
$(".edit_area").editable('http://my_cgi_url', {
event : 'dblclick',
type : 'textarea',
rows : 3,
cols : 30,
cancel : 'Cancel',
submit : 'Save',
indicator : '<img src="images/indicator.gif">',
placeholder: 'Double Click to enter text',
tooltip : 'Double Click to edit...',
name : 'comment'
});
//Please note there is another peice of code which is capturing clikc events inside the table columns,
// which goes like this...
//I doubt it is catching the double-click before the above function....
//I am not sure how to make the editable catch the doubleclick event??....
var rowi, coli, cellval; //global as called in other subroutine too....
$(".mytbl tbody tr").live('click',function (e) {
rowi = this.rowIndex;
coli = e.target.cellIndex;
cellval = $('tr').eq(rowi).find('td').eq(coli).text();
var propvalue = $('tr').eq(0).find('th').eq(coli).text();
//and some other functions.....
});
});
HTML SAMPLE 一个表记录:edit_area div 的 id 对于每个表行都是唯一的。
在页面加载后通过 ajax 调用添加表格 - 因此页面加载时页面中不存在 id/div 等。只有 div mytbldiv 始终存在于页面上。
<div id="mytbldiv">
<table class="mytbl" border="1">
<tr><th>header1</th><th>Header2</th></tr>
<tr><td>A</td><td><div class="edit_area" id="uniqelementid_forthisrow">text_to_edit</div></td></tr>
</table>
</div>