How can i access a variable in opal-ruby code that has been previously defined in javascript? For example in the following code how to fix the opal file.
...
<script>
var test = "hi"
</script>
...
Document.ready? do
puts test
end
Opal lets you use backticks to output any raw JavaScript that you don't want Opal to interpret, so this will output your test
string containing "hi":
Document.ready? do
puts `test`
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.