Losing connection with HtmlDialog

Re the object access and “not a function” error:
The UI::HtmlDialog class can loose it’s callback attachments (especially if you close the window and reopen it with the same Ruby object.)

So what I do (usually) is put all the callback definitions within a method I (usually) name “add_callbacks()”. This way you can call the method and reattach the callbacks anytime.

ADD: I also pass the dialog object into this method.

It’s likely that reloading of the html document may break the attachments of the Ruby callbacks. You might add a JavaScript error handler function to detect the “not a function” error, and send a request over to Ruby (hopefully by a still functioning callback) to reattach the callbacks.
Other than that perhaps a Ruby timer that sends “pings” to the dialog every so often and if the dialog does not respond back in a certain amount of time, then the Rubyside goes ahead and reattaches the callbacks.

The only I’ve seen that error myself is when I tried to call a callback from JS that did not have any parameters, and I omitted the parenthesis, ie …

sketchup.close_dialog;

… instead of …

sketchup.close_dialog();
1 Like