opal icon indicating copy to clipboard operation
opal copied to clipboard

[Documentation request] Please provide a simple standalone .html example (via opal-generated code) to demonstrate how the user clicks on a button, and then a function is called in a ruby class

Open rubyFeedback opened this issue 3 years ago • 2 comments

I finally got opal to work and I compiled some app.js file, which I then used via a test.html page. It's the hello world example. The dev console shows "Hello world!" so it works. But now I am not sure how to proceed from here. I looked at the examples but they seem a bit like unorganized fragments.

Would it be possible to add a NEW example, at:

https://opalrb.com/docs/guides/master/

With SPECIFICALLY this content to be tested:

  • A button in a standalone .html page. (The javascript is compiled into a standalone .js that is included in that .html page then)
  • On clicking the button a method is called in a ruby class (but part of that .js file) that uses an alert-box to say hello world and fetches some value from a formular such as the name of the user. So a button and a form field.

This can be kept as simple as possible. I would like to know how I can work with data from a form field, and how to use a button to call that.

rubyFeedback avatar May 28 '22 02:05 rubyFeedback

There should be a basic howto for opal-browser there I agree. But for now, you can take a look at opal-browser's readme:

https://github.com/opal/opal-browser

hmdne avatar May 28 '22 18:05 hmdne

Agreed, I had to find this github issue to learn that opal-browser should be used. The docs need way more organization.

jtoy avatar Aug 19 '22 23:08 jtoy