Editor Dependent - Simple Question

Editor Dependent - Simple Question

edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

Hi, i would like to ask a simple question.

How can i disable Editor Dependent to be fired when the editor form is created.
I mean,
{event : change}

Cause i have a select box in the form which fills another field upon change.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,054Questions: 1Answers: 10,173 Site admin

    There is no option for that. The reason being that when you start an edit, the existing value will be set and used. Likewise when creating a new row, the default value will be set and the dependent method will update based on that.

    Allan

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    If i use condition for initcomplete for editor, will it be a solution?

  • allanallan Posts: 62,054Questions: 1Answers: 10,173 Site admin

    Possibly - but I'm not sure I really understand how you would use it. I don't actually even fully understand the problem.

    Allan

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4
    edited February 2017

    Hi Allan,

    Here is the screen shot of the editor form.
    I have a select box, and a note field.
    When the user changes the option in the select box, it fills the note field with predefined values. We can say they are offer details like a template.

    It is working, but the only problem is, when i edit a record, i need to stop select box being fired at the beginning.

  • allanallan Posts: 62,054Questions: 1Answers: 10,173 Site admin
    Answer ✓

    Thanks for the details. For this I would recommend not using dependent(), but that rather use a simple change event - e.g.:

    $( 'select', editor.field( 'myField' ).input () ).on( 'change', function ( e, d ) {
      ...
    } );
    

    When the value is being set by Editor you can use if ( d && d.editor ) { ... } to check for this. If the value is set by the user that expression will not be true.

    Allan

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    Thank you Allan,

    Got it working :)

This discussion has been closed.