Michael Neumann
1/14/2007 11:00:00 AM
Am Sonntag, 14. Januar 2007 09:05 schrieb Une Bévue:
> Michael Neumann <mneumann@ntecs.de> wrote:
> > With RubyJS you can transform a subset of Ruby into Javascript code.
>
> yes but how to interact with the browser window, for example, say i have
> a :
>
> <pre id="STDOUT"></pre> in the html document and i want to redefine ruby
> puts like this :
>
> def puts(str)
> document.getElementById('STDOUT')['inneHTML'] += str + "\n"
> end
>
> if i do that into your HelloWorld class i get errors :
Well, does it work in Ruby? NO! So it doesn't work in RubyJS as well :)
It's a bit more advanced than converting "document" from Ruby plainly
into "document" in Javascript.
If you want to insert Javascript code directly into your Ruby code, use
backticks:
def puts(str)
`document.getElemementById('STDOUT')['innerHTML'] += str + "\n"`
end
In the next step, I've planned to port Google's Webtoolkit (or Python Pyjamas)
to RubyJS.
> method_generator.rb:1040:in `method_missing': Not implemented
> (RuntimeError)
> [...]
>
> is their a way to let RubyJS knows that "document.getElementById..." is
> allready JS ???
See above :)
Regards,
Michael