add_action('wp_enqueue_scripts', 'resources_enqueue_custom_js');Any help would be greatly appreciated.
function resources_enqueue_custom_js() {
wp_enqueue_script('custom', get_stylesheet_directory_uri().'/custom.js', array('jquery'), false, true);
}
Your action loads the jQuery globally. If you want it to load only for your form, you can place the jQuery in the After Fields area on the form's Customize HTML Page.
I'll bet your code works for the first row of the repeater and then it stops working. Is that correct?
The code you are using will work on forms without repeaters. Repeaters are actually embedded forms. Subsequent rows are single form entries that are created through Ajax and attached to the embedded form. jQuery is loaded when the page is fully rendered in the browser when it is initially loaded into the page's HTML Document Object Model (DOM). Because subsequent repeater rows don't exist in the DOM until later when they are created through Ajax, the jQuery cannot interact with these new rows until it is reinitialized for the newly remodeled DOM. See this article to learn how to reinitialize the jQuery so it works for all repeater rows. https://formidable-masterminds.com/repeaters-and-complex-jquery-operations/
Thanks Victor for your quick response. I have removed the add_action() code and placed the in the After Fields box for the form. It does not seem to trigger on the change event of either time field.
After some further debugging I found that there is not a single field #field_hlbr1
but it is split into hours and minutes in the front end.
I see #field_hlbr1_H an d #field_hlbr1_m
Do you think that the same code needs adjusting to work?
Please login or Register to submit your answer