可编辑的可编辑例程不会触发

时间:2012-10-03 19:34:41

标签: jeditable

以下是我的代码。双击事件不会被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 / divs等。只有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>

1 个答案:

答案 0 :(得分:0)

必须使用javascript代码运行editable,这会将新表添加到页面。这样它就可以正确地附加到元素上并按照需要工作。