AnsweredAssumed Answered

Detect change in "date" field (sugar 6.5)

Question asked by Robert Sinclair on Apr 1, 2019



There's a date field and I want to detect when it changes through Javascript (so I can toggle visibility of other fields on the screen).


What I have tried:
I tried attaching displayParams on the field in edit view to try to detect the change with


'displayParams' => 
   array (
   'javascript' => 'onchange="yourCustomFunction(this)"',




Also tried


'displayParams' =>
   array (
   'updateCallback' => 'yourCustomFunction(this);',



But to no avail.


Regular approaches that work with text fields like attaching an event listener as in:


field_name.addEventListener('change', yourCustomFunction, false);


Also fail. It simply never picks up the change.


Seemingly trivial task, but completely stuck at this point, my only solution is to track every click on the screen and

check the before and after value of the date field. But this is extremely inefficient.