I have a Ruby function translated into JS by Opal that has always worked fine, but suddenly it does not work anymore. The JS console gives me this error message
Opal.const_get_relative is not a function
The original Ruby code is this
Document.ready? do
Element.find('#button_id').on :click do
Which translates into this
return $send(Opal.const_get_relative($nesting, 'Document'), 'ready?', [], (TMP_1 = function(){var self = TMP_1.$$s || this, TMP_2;
return $send(Opal.const_get_relative($nesting, 'Element').$find("#button_id"), 'on', ["click"], (TMP_2 = function(){var self = TMP_2.$$s || this, TMP_3, postcode_value = nil, blokouderling = nil, content = nil, wijk = nil, naam = nil, email = nil, $writer = nil;
Any idea what goes wrong?
The easiest way to compile an opal app to a file outside of Rails is to build the JavaScript file with
Opal::Builder
, here's a simple example with both Opal and jQuery:At that point you can just open
app.html
with your browser to see the "hello world" message popping up in an alert.