Avoid that dependent() is fired on form create

Avoid that dependent() is fired on form create

datacollectdatacollect Posts: 6Questions: 4Answers: 0
edited July 2015 in Editor

Hi,
is it normal, that this code

editor.dependent( 'position', '/ajax/update-position', {
  event: 'change'
});

will fire an ajax request, when the form is created? I only want to fire it, when the specified field (select) is changed.

Answers

  • datacollectdatacollect Posts: 6Questions: 4Answers: 0

    It doesn't have to be a bug, but it would be nice, if its controllable. Or did i missing an option?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    I missed your thread before - sorry about that!

    Yes, this is expected behaviour as the value is changed at that point - more specifically it will set the field's value to be the default value (usually an empty string). Part of the reason for this is if you have been editing a field previously then the value it holds would be that old value and you want it to be replaced with the default value.

    If you really don't want the event to occur, you would need to attach attach and remove the listener every time the form is opened and closed - although I think that could lead to unexpected behaviour.

    Allan

This discussion has been closed.