I have one field (field2) which value depends on another field (field1).
Basically, when field1 changes, the values from field2 will need to be updated, as they depend on field1.
I assume that there are 2 ways to achieve this:
- detecting onChange
- configure a dependent field
Detecting onChange
editor.field('field1').input().on('change', function (e, d) {
if ( d && d.editor ) return;
//Code to change field2 according to field1 value ($(this).val())
});
configure a dependent field
editor.dependent( 'field1', function ( val ) {
//Code to change field2 according to field1 value (val)
} );
I'm using the following versions:
Jquery: 1.12.4
Datatables: 1.10.16
Editor: 1.7.3
KeyTables: 2.4.0-dev
Select: 1.2.5
I have two specific questions:
- Which is the best approach?
- On method 1), using onChange, the value for d.editor is ALWAYS true, even if i the user changed the value
Thank you very much.