I have a custom control, which I made from the TinyMCE-Editor.
It was my first WebSDK-project, so I had to learn a lot of new things.
My control is running fine, if I place it at runtime into the Webpage. In this case everything is okay.
But if I create it dynamicly, for eample within a dialog, the control works only once.
If I create a second dialog with the control inside, the JS-Librarys won’t run.
Have you tried loading the libraries via the WebHook shared method. I never even use the other methods. They’ve always been problematic for me. The WebHook also allows you to load the libraries in the header.
[quote]Hooks
HTMLHeader(CurrentSession as WebSession) as String
Override this shared method to dynamically add items to the section of the session as it loads. This method is called when an end users session is first being created and no control instances have been created yet. You may use the CurrentSession parameter to examine the Session that is being created to load different headers based on Session conditions. See the jQueryCalendar project for a usage example. ?
New in 2014r2.[/quote]
If I create an instance of my CustomControl nothing happens, except I do run the ‘LoadLibraries’-method.
But this works only once. If I open a socond instance of the CustomControl it doesn’t work.
So how can overwriting the HTMLHeader help me? I don’T understand …
So you’ve got a few things going on which are incorrect:
JavascriptNamespace Constant - This should be your namespace. If you’ve registered “doit” then use that.
The LoadLibraries method is asynchronous, so you’ll need to write some javascript to call when they are done. I’d suggest using a single call instead of two the way you’ve done this because the second likely relies on the first being there:
self.LoadLibraries("JS1", ScriptLocation + "/tinymce/js/tinymce/tinymce.min.js", _
ScriptLocation + "/tinymce/js/tinymce/tinymce1.js")
3. Use your namespace for the callback function:
self.LoadLibraries("XojoCustom.doit.loaded()", ScriptLocation + "/tinymce/js/tinymce/tinymce.min.js", _
ScriptLocation + "/tinymce/js/tinymce/tinymce1.js")
4. Define XojoCustom.doit.loaded so that it sends a “ready” event back to the app so you can initialize it.
I’d suggest reviewing the WebSDK docs (available in the Extras folder next to the IDE). It’s relatively short, but it should give you a better understanding of why this stuff isn’t working. For instance, there’s no easy access to global variables… everything should be in your defined namespace because that’s how we keep your code from colliding with someone else’s code. There’s even an example project showing the YUI HTML Editor.