Binding the click event of a row with jQuery

前端 未结 1 435
礼貌的吻别
礼貌的吻别 2021-01-28 01:52

I am creating a demo in which button clicks trigger the creation of rows. I want to edit the row\'s text when I click the generated row \"it generate another row inside containe

1条回答
  •  广开言路
    2021-01-28 02:52

    Working example: 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;
    }
    

    Tell me if you need anything else.

    0 讨论(0)
提交回复
热议问题