precisions about dependent() 2 questions.

precisions about dependent() 2 questions.

UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

Hello everybody.
First:
Anybody could explain me the difference betwwen
1) editor.dependent('individual.id', console.log('tata'), {event: 'change'});
and
2) editor.dependent('individual.id', function(val, data, callback) {console.log('toto');}, {event: 'change'});

In my console 1) make one 'tata' 2) make two 'toto'. Why ?

Second. When i open the editor, an event 'change' is detecting why ? (so i have 'tata' and 'totox2 in my console. I would like detect changes in certain fields but not when the editor is open. Is it possible?
Thanks a lot.
Lionel

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    editor.dependent('individual.id', console.log('tata'), {event: 'change'});

    This executes the console.log() when that editor.dependent... line of code is executed. The result from console.log() (which is undefined) is then passed as the second argument to dependent().

    In the second example you have a callback function, so console.log() is executed whenever the change event happens on the input element in question.

    When i open the editor, an event 'change' is detecting why ?

    Because the value has to be set in order to be editable.

    Allan

  • UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

    Hello thanks a lot Allan.
    I don't really understand your answer for my 2nd question. Could you please help me to find a example on the datable web site ?
    I need to detect any event changing my individual.id field when my editor is open, but not when my editor is open.
    Thanks a lot.
    Lionel

  • UMR5558UMR5558 Posts: 41Questions: 13Answers: 0

    Sorry.
    I need to detect when I input a new value in individual.id field or when the values is changed by another field, but not when my editor is open.
    Thanks a lot.
    Lionel

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Try:

    editor.field('individual.id').input().on('change', function ( e, d ) {
      if ( d && d.editor ) {
        // Set by Editor
      }
      else {
        // Set by user
      }
    } );
    

    I'm with you now. dependent() doesn't provide that information, but the above code does through the data parameter passed into the event handler.

    Allan

This discussion has been closed.