Html dialog box to set and get information

… Now, all that said …

My actual examples are doing the “heavy work” on the Ruby side using HTML, JS and CSS file fragments and Ruby text strings. I build up the dialog webpage in Ruby using one of 2 Ruby String class parameter replacement methods.

Either … String#% or String#gsub.

Both of these methods will accept a Hash of replacement values that replace all the %{param_name} substrings in the text with the values from the hash with the matching :param_name symbol key.

I do this replacing on JS and CSS file text if I need to set dynamic changing values in the stylesheet and / or the dialog’s JavaScript code.

Then I build up a data list in HTML using a HTML file fragment for one line of data that has several %{} parameters for the data fields. I do this in an iterator, appending each HTML fragment to a list string object.

Lastly before giving the html text to the dialog object, I replace a couple of %{styles} and %{script} parameters in the main HTML file for the dialog, with the CSS and JavaScript code text, as well as replacing the %{datalist} parameter in the HTML’s <div> element where it will “live” in the webpage.

Then I do a dialog.set_html(htmlpage) and show the dialog.

We cannot get away from using some JavaScript as we must create event listeners for button clicks and edit control changes.

1 Like