HTMLDialog Fill inputbox from csv data

(1) Stuffing everything into one method is somewhat clunky and hard to follow, not as easy to maintain if it were broken up, with the ruby, javascript and html in their own files.

(2) The acts of saving to disk and loading from disk are a separate task then passing to an HTML dialog and receiving changes back.

But you understand using a Ruby Hash and iterating it to write or read from CSV. This is good.

A Ruby Hash can also easily be converted to JSON passed into the dialog JavaScript creating a JS Object. This can be changed and set back to a Ruby callback automatically converted back to a Ruby Hash.


See the (collapsed) example go() method at the bottom of this post:
HTML How to delete a line with a text field and button when the button is clicked - #29 by DanRathbun

Or also a condensed general example here:
`UI::HtmlDialog`: global `sketchup` object in dialog has no callbacks when viewing page served remotely after being linked from a local html file · Issue #646 · SketchUp/api-issue-tracker · GitHub

I also discuss it at length in this topic:
Html dialog box to set and get information - Developers / Ruby API - SketchUp Community

1 Like