Jump to content

Inputfieldform loaded via AJAX


swissdoode
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...