使用jQuery绑定行的click事件

我正在创建一个演示,其中按钮单击触发创建行。 当我单击生成的行“它在容器内生成另一行”时,我想编辑行的文本。 我们可以选择在单击编辑按钮时更改行的文本吗? 当你的印刷机完成时,它会弹出一些东西,将文字保存在相同的ID上吗?

http://jsfiddle.net/k7zJ4/2/

function createTestCase(testCaseName, iscreatedFromScript, jsonObject) { var id; if (typeof ($("#testCaseContainer li:last").attr('id')) == 'undefined') { id = "tc_1"; } else { id = $("#testCaseContainer li:last").attr('id'); var index = id.indexOf("_"); var count = id.substring(index + 1, id.length); count = parseInt(count); id = id.substring(0, index) + "_" + parseInt(count + 1); } var html = '
' + '' + '
'; $('#testCaseContainer').append(html); var elem = document.getElementById('testCaseContainer'); // just to scroll down the line elem.scrollTop = elem.scrollHeight; }

工作示例: http : //jsfiddle.net/Gajotres/k7zJ4/5/

HTML:

    jQM Complex Demo     

First Page

Next
Close
Done

JavaScript的:

 $(document).on('pagebeforeshow', '#index', function(){ $(document).on('click', '#addTestCase', function (e) { $("#testCaseId").popup("open"); //createTestCase("trdt",false,null); }); $(document).on('click', '#donePopUp', function (e) { $("#testCaseId").popup("close") }); $( "#testCaseId" ).on({ popupafterclose: function() { if($('#testCaseIDValue').val().length > 0) { createTestCase($('#testCaseIDValue').val(),false,null); } } }); }); function createTestCase(testCaseName,iscreatedFromScript,jsonObject) { var id; if (typeof ($("#testCaseContainer li:last").attr('id')) == 'undefined') { id = "tc_1"; } else { id = $("#testCaseContainer li:last").attr('id'); var index = id.indexOf("_"); var count = id.substring(index + 1, id.length); count = parseInt(count); id = id.substring(0, index) + "_" + parseInt(count + 1); } var html = '
' + '' + '
'; $('#testCaseContainer').append(html); var elem = document.getElementById('testCaseContainer'); // just to scroll down the line elem.scrollTop = elem.scrollHeight; } $(document).on('click', '.clickTestCaseRow', function (e) { var clickId=this.id; e.stopPropagation(); }); $(document).on('click', '.clickTestCaseRow', function (e) { var clickId=this.id; e.stopPropagation(); });

CSS:

 #testCaseId { margin-top: 170px; width: 400px !important; margin-left: 150px !important; } 

告诉我你是否需要其他任何东西。