Dependent() only once and not infinit times

Dependent() only once and not infinit times

CapamaniaCapamania Posts: 233Questions: 81Answers: 5
edited August 2016 in Editor

I want to .search().draw() or .ajax.reload() a table based on a select change of an editor field. In both attempts, the below filtering or the reload, the request runs 'infinite' times. How can I trigger it only once?

editor_table.on( 'open', function ( e, o, action ) {
        if ( action !== 'remove' ) {

        editor_table.dependent( 'coulmn_01', function () {

            var getColumn01 = editor_table.field( 'coulmn_01' );

            // Attempt 1:
            var getSearch = table.column( 1 ).search(getColumn01.val()).draw();
            
            var getCache = table.column( 1 ).cache( 'search' );
            
            // Attempt 2:
            table.ajax.reload();

        } );             
    }
} );

The select list is coming from the server and JOIN table similar to the 'sites' example in https://editor.datatables.net/examples/simple/join.html.

->options( 'column_01', 'id', 'name' )

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Hi,

    Probably the best way to do this would be to attach your own change event listener to the input in question rather than using edependent() (which currently cannot be removed - I'll look into adding that ability).

    Using field().input() you can get the input element and add the event listener, which is actually basically all dependent() does.

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5

    Ok, thanks a lot Allan!

This discussion has been closed.