swissdoode Posted April 16, 2022 Share Posted April 16, 2022 Hi everybody I'm loading an Inputfieldform via AJAX (rendering the form with $form->render(), passing it back to the calling JS and injecting it into the DOM). This basically works - but the javascript that handles inputfield-actions (like conditional display) is not initialized. How do I manually initialize the js-actions of the form? I found a javascript-file for each possible inputfield. But they're using only $(document).ready()-Events, which can't be called after an AJAX-return. Any ideas? Link to comment Share on other sites More sharing options...
swissdoode Posted April 16, 2022 Author Share Posted April 16, 2022 Naturally, after posting my question, I figured out a way (which is kinda cumbersome, though). I just reload the entire page content using $('body').html($('body').html()) This triggers all page load events again. But it also reloads all JS basically reloading the page. If there's a better way to do this (meaning, just re-initializing the form), that'd be great. Link to comment Share on other sites More sharing options...
Zeka Posted April 16, 2022 Share Posted April 16, 2022 Hi @swissdoode . Take a look at Inputfields.js file, there are many methods that you could find helpfull https://github.com/processwire/processwire/blob/dev/wire/templates-admin/scripts/inputfields.js#L37 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now