javascriptjquerymodal-dialogatk4agiletoolkit

Agile toolkit - how atk4_form.js is loaded?


I'm using agile toolkit version 4.2. I'm using a javascript function that creates a modal (popup) and the content is inserted via ajax call. The content was inserted via jquery's ".html()" function but in case of big data, this function is very slow.

I replaced this function with the plain javascript function ".innerHTML".

But now, the atk4_form.js is not loaded anymore and I don't know why. Is there any hook on the jquery's "html()" function? All the content events are called when I use "html" but none of them is called when I use "innerHTML".

I know that the class "Form_Basic" loads tht atk4_form.js in the "render" function. But there must be some hook for the render also that is pointed to jquery's "html" or "append" functions.

Any idea how can I load atk4's base functions when I use javascript function "innerHTML"?


Solution

  • You need to look for tag inside the server response and execute it in the context of the element that triggered window open event. If you are not doing anything fancy, then simply eval() the block(s).

    the loader was written quite some time ago, see file start-atk4.js.

    The javascript is wrapped inside $.atk4(function(){ .. }); which is similar to $(function() { }); but slightly extended.

    Most likely the execution is done through ui.atk4_loader.js which is jQuery UI widget designed to safely load page regions.

    To answer your question you should make copy and amend this file here:

    https://github.com/atk4/atk4/blob/develop/public/atk4/js/ui.atk4_loader.js#L201