closed
Public

Hello dear ForeUI team,

with the possibility of custom JS Code and JS snippet call, I can do almost everything I need with your tool.

However there is a small limitation caused by the way the index.hmt is generated.

As you can see in the screenshot, my custom functions are stored in the page div and are loaded before JS libraries.

From “element relation” point of view, this behavior is right, because the JS Code element is in the page div.

But since it is parsed as script element(without any relation to other page elements) anyway, the page relation is not that important compared to the lack of using JS libraries.

I think it would be great to have the possibility to use e.g. jquery-ui in my functions, instead of calling always the whole code in the JS snippet.

What do you think?

3 answers

For the ones, who need this feature now, I found a little workaround:

– Place your custom code in a file, e.g. custom.js

– Place in your plot a plain JS Code element e.g. on Page 1

– Create an event(click, loading, …) to trigger JS snippet action only once

– Write following line into the JS snippet:

$(“#Page_1 script”).attr(‘src’, ‘file:///D:/yourFolder/custom.js’);

With this trick you can also load another JS libraries and manage your custom functions from one file/place in many plots at the same time :)

#1

Hi Oleg, thanks for the suggestion!

I agree that the custom script should be placed after all libraries are loaded, and we will improve it in next SP version.

Meanwhile your workaround is great :-)

#2
  1. Will it be possible to set a path to a custom.js file in the editor?
    I think, it makes handling custom functions much easier, than keeping the Code Elements up to date for every plot :)
  2. You can insert the <script> tag with "src" specified by using the Html element, although it will not be placed after those JS libraries.

The enhancement is made in V3.80 SP5

#3

This question is now closed