如何以适当的方式动态创建输入复选框

时间:2018-07-25 14:05:23

标签: javascript jquery ajax

我一直在尝试使用ajax的成功函数创建一个复选框, 表中的所有数据都已正确创建,但是我的输入复选框未出现在表中,但是如果我更改为按钮,则该按钮有效,只是该复选框不起作用。 我该如何解决? 谢谢。

         function createTableByJqueryEach(data)
        {


            var eTable=`<table class="table">
                <thead class="thead-light"><tr>
                <th scope="col">Nome da Instituição</th>
                <th scope="col">Categoria</th>
                <th scope="col">UF</th>
                <th scope="col">Responsável</th>
                <th scope="col">E-mail</th>
                <th scope="col">Nota</th>
                <th scope="col">IAD Conh.</th>
                <th scope="col">IAD Apli.</th>
                <th scope="col">Enviar Ubc</th>
                </tr>
                </thead><tbody>`

            $.each(data,function(index, row){                
                eTable += "<tr>";
                $.each(row,function(key,value){     
                    if(value['ubc'] !== undefined){
                        eTable += "<tr><td>"+value['ubc']['name']+"</td><td>" + value['ubc']['partner']['title'] + "</td><td>"+value['ubc']['uf']+"</td><td>"+
                            value['ubc']['coordinator']+"</td><td>"+value['ubc']['email']+"</td><td>"+ parseFloat(value['nf'].toFixed(3)) +"</td><td>"+
                                parseFloat(value['ap_grade'].toFixed(1))+"</td><td>"+parseFloat(value['kn_grade'].toFixed(1))+"</td><td><input type="checkbox"></td>";
                    }                   
                });
                eTable += "</tr>";
            });
            eTable +="</tbody></table>";
            $('#eachTable').html(eTable);
            }


    $('#taxo_id').click(function(){
        var radio_option = $("input[type='radio']:checked"); 

        var ubcs = JSON.parse('{{ubcs}}')


        $.ajax({
            url:"/api/v1/oportuniy/diogoreturn/",
            type:"GET",
            data: {
                option:radio_option.val(),
                oportunity: '{{oportunity.id}}',
                filter:'{{filter_oportunity.id}}',
                ubcs:ubcs
            },
            dataType:'json',
            success: function(data){
                createTableByJqueryEach(data);                

            },
            error: function(data){                    
                swal({
                    title:'Atenção!',
                    text:data['responseJSON']['error'],
                    icon: "warning",
                    buttons: true,
                    dangerMode: true,
                });
            }
        });
    });

0 个答案:

没有答案