Add_action_callback problem

(1) Ruby uses 2 space indentation. This helps also minimize horizontal scrolling in forum snippets.

(2) All API observer classes are abstract.

  • This means that you gain nothing by subclassing them as they have no superclass functionality to pass down to subclasses.
  • All observer attach methods do no class checking at all. This means that any kind of object can be an observer, of any kind, at all times. Ie, hybrid observer objects.

So basically your use of the Html_Update as a class is not correct. You only create a class if your code will be making many instances of such class.

You don’t need a class here. Just use an extension submodule (ie, IndexZ) and extend it with itself …

module Zhouxi
  module IndexZ

    extend self

Now you methods can be called without the self. qulaification.

(3) For HTML, …

  • <meta> tags need to be within the <head> element.
  • Your HTML should always begin with a <!DOCTYPE html> tag. (ie, the 1st line before <html>.)

(4) Your add_action_callback must be called before you create the dialog with #show.

  • AND … if the user closes the dialog, and then your code opens it again (say, with a toolbar button) then you must reattach the action callback proc. (Closing a UI::HtmlDialog instance window breaks the link to the callback procs.)

(5) Outdenting SUCKS. Please don’t do this. Outdenting breaks the editor’s indent guidelines.

(6) Avoid the use of @@ class variable references unless you really understand how to use them.
In your case, you should really only be using @ instance variables of the extension module’s instance. (Meaning, a module is an instance of class Module. So it can have it’s own instance variables.)

Learn how to build hashes of Ruby object data, then create a JSON string of this hash.
Then pass the JSON string to the HTML using #execute_script.

SEE: