Hey everyone, I am facing an issue regarding saving the Observation form when I click on Save button!
When I’ve added customized functional java-script to be called on button click event either “6 months or 12 Months” before saving to the database, it’s responsible to detect when the next Visit date and will be auto filled depending on previous visit date, though date is automatically calculated but on saving to database it’s saved as null
I’ve attached a sample video photo for script_file showing what’s going on behind the scenes.
Here the GIF illustrating what’s going on
CC: @angshuonline , @binduak , @rubailly
I think the culprit is the
.val( ) function call. See this:
Also, when I look at documentation for
val( ) it says:
Setting values using this method (or using the native value property) does not cause the dispatch of the change event. For this reason, the relevant event handlers will not be executed.
So, i suggest try the method mentioned in the stackoverflow link above to set the value. Hopefully this fixes the problem you see.
Thank you @gsluthra for your reply, I’ve followed the suggested solution under stackoverflow unfortunately didn’t work , but by help of the link you shared too I took time and read whole statement saying about not causing any dispatch of the change event either you used val() or attr(‘value’,‘…’) by triggering this event to be executed we have to add .trigger(‘change’) so that it will listen to any event as if end-user picks date manual.
briefly by appending .trigger(‘change’) it makes it to be saved to database