WebSDK - Control works only once


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.

Here is a testproject:


I worked with the examples and the documentation, but I can’t find a solution.

-> why do the control works only once?

Thanks a lot!

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.

WebHook? Can’t find it in the Docmentation. Could you explain what it is and how to use?

From the documentation:

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 user’s 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]

Ah ok,
But, I have the JS-Libraries on an extern place:

http://c-doit.de/develop/tinymce/js/tinymce/tinymce.min.js http://c-doit.de/develop/tinymce/js/tinymce/tinymce1.js

Also I have it in the HTML-Header:



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 … :confused:

Thanks a lot!

Jea, I’ve placed it there now - same result :confused:

So you’ve got a few things going on which are incorrect:

  1. JavascriptNamespace Constant - This should be your namespace. If you’ve registered “doit” then use that.
  2. 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.