2

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"?

Pascut
  • 3,291
  • 6
  • 36
  • 64

1 Answers1

2

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

romaninsh
  • 10,606
  • 4
  • 50
  • 70
  • Thanks, my data length is 800 000 and jqyery's "html" load time takes 6 seconds while javascript's "innerHTML" takes 0.41 seconds. Who want to wait more than 7 seconds for a popup to appear? – Pascut May 03 '17 at 17:06
  • Then it's wrong by design in your page. It's useless to show such big data table to a client without paginator. InnerHTML surely is faster, but as far as i know it will not run scripts and do all that fancy stuff which jQuery html() does. – DarkSide May 03 '17 at 19:32
  • Also you should check out ATK version 4.3 and new https://github.com/atk4/ui and https://github.com/atk4/data :) – DarkSide May 03 '17 at 19:33
  • @Pascut, maybe using up-to-date jQuery would have optimized html() method, I'm not sure why it takes so long. Regardless - if you manage to get the scripts working fine, please share :) – romaninsh May 03 '17 at 20:52