Jquery function does not refresh

Jquery function does not refresh

andras2andras2 Posts: 31Questions: 12Answers: 0

Hi,

In my code there is a .text Jquery method to refresh a HTML input text field as $("#project_title").text(data.id).
When the application loads it refreshes fine, but when I do manual correction it stops working. Can you help me, please?

<script>    
$(document).ready(function() {  
    var table = $('#example').DataTable( {
        select: true,
        stateSave: true,
        //ajax: '/api/staff',
        rowId: 'id',
        columnDefs: [ {
            orderable: false,
            className: 'select-checkbox',
            targets:   0
        } ],
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
        order: [[ 1, 'asc' ]],
        "ajax": "data.txt",
        "columns": [
            { "data": "select" },    
            { "data": "id" },
            { "data": "title" },
            { "data": "description" },
            { "data": "cost" },
            { "data": "start_date" },
            { "data": "end_date" },
            { "data": "image_url" }
        ]
    } ); 
    ////
    $('#example tbody').on('click', 'tr', function () {
    var table = $('#example').DataTable();
    var data = table.row( this ).data();
    alert( 'You clicked on '+data.id+'\'s row' );
    $("#project_title").text(data.id);
    $("#project_description").text(data.description);
    $("#project_cost").text(data.cost);
    $("#project_date_start").text(data.start_date);
    $("#project_date_end").text(data.end_date);
});
    ///
    setInterval( function () {
        var rows = table.rows({selected: true});
        table.ajax.reload( 
            function () {rows.select()}, false );}, 
            1000 );
});
</script>

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

Sign In or Register to comment.