I am using the SetupJavascriptFramework the code of two frameworks, namely jQuery and W2UI. The respective source code is stored in a constant each, I am using this code:
[code]Function SetupJavascriptFramework() As String
dim src() as string
src.append jQuery
src.append W2UIJS
return join(src, EndOfLine)
End Function
[/code]
Though, it does not seem to be added to the page source code, can’t find the Javascript code anywhere. Where do I need to look?
Are your libraries modified in any way? If not, they’re going out of scope as soon as they reach the page. When items are executed in this way, they must be placed into your namespace if you want them to persist.
I suggest loading each library into a WebFile and then using LoadLibraries to pull them from the server.
I did that now. They are now being included in the html header. So good, so far. But they still don’t work. Do I need to use the callback parameter with LoadLibraries? I left it empty for the moment.
I reconstructed the very simple get startet example both in an html file and Xojo project (using the wrapper class). In the plain html file, everything works as expected. Within Xojo, it doesn’t - though the source code in Chrome’s inspector looks okay.
I know that “not working” is a worse error description - but since nothing happens really (yes, I set visibility) and the lack of JS/html debugging capabilities, I am having a hard time debugging…
Remember that LoadLibraries is asynchronous. If you are calling LoadLibraries and then trying to execute that code immediately afterward using ExecuteJavascript, you’ll have problems. What you could do is create a custom event that gets triggered from the callback to let you know when your libraries have been loaded.
Oh okay. I’ll get that done. However, when I used the SetupJavascriptFramework event it didn’t work either. But that might be because SetupHTML gets called before that event.
XojoCustom.MyNamespace.id.on(‘*’, function (target, eventData) {
Xojo.triggerServerEvent(“id”, eventData.type, JSON.stringify(eventData));
});
};[/code]
id is being replaced by the control’s id. The function _libraryLoaded is the callback method called by LoadLibraries. Still I get the message: "Uncaught TypeError: Cannot call method ‘w2grid’ of undefined ". Is this still not persistent and already went out of scope?
for me it’s working so your probably doing something wrong.
It’s very complicated to work with the WebSDK in the beginning. Once you get the hang of it, then it becomes somewhat easier.