2012-10-03 46 views
0

以下是我的代碼。雙擊事件不會被可接受的事件捕獲和執行。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樣品中的一個表記錄:爲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> 

回答

0

可編輯必須使用JavaScript代碼運行,該代碼將新的表格添加到頁面中。這種方式正確地連接到元素,並按需要工作。