External libraries: Clarification needed

Hi all,

I am having troubles wrapping my head around the concept of the WebSDK and external libraries.
I need to include two libraries, jQuery and one that builds upon jQuery.

So in the Open event, I load those libraries using LoadLibraries and pass a callback function that then implements the included functions (of those libraries) in my custom control. I register the libraries with RegisterLibrary so I can check in a second instance if I need to call LoadLibraries or if it’s already been sent to the browser. So far, so good.

However, after having loaded the jQuery library and calling the famous “$” function (to obtain a DOM-handle), Xojo interrupts and says: “Could not execute returned javascript: $ is not defined”. The DOM however clearly shows that the library is loaded (it’s included in the head-tags) and the function get’s called (in the shown event) after the library has been loaded (in the open event). Could it be that the library hasn’t actually been loaded even though the shown event has already been called?

Debugging JS in the WebSDK is still a pain in the /\$$…

Thanks for your support,
Alex

If you’re using 2014r2.1, theres a new way to get your libraries onto the page. Add a Public Shared Method to your control:

HTMLHeader(currentSession as WebSession) as String

Return the script tags to load your static libraries there. Something like:

<script src="Mylib.js"></script>

This method is called once per class. If you get errors, make sure the method is Public.

Yeah, just found it and it works :slight_smile: The docs are missing any hints and the SDK PDF docs don’t mention the return type…

Huh. I just looked at the WebSDK iBooks file and on page 17 it says:

HTMLHeader(CurrentSession as WebSession) as String

Where are you looking?

Hum, don’t know. Must have been blind :-/ Apologies

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.