Thanks, for the quick reply -
I actually read your article earlier on thanks.
Hmm, now lets see if I am getting this right.
When I write somthing in the RJS file the page object takes my DLD and
transforms it into javascript which is immediatley sent out to the
browser which then does the rendering it has been asked for.
I hope I got that bit right?
Yup.
As it is possible to send snippits of javascript to the browser and ask
it to get me a value of a DOM back, then I ask by self why this request
cannot be handled by the javascript engine in rails.
The only logical explination to me is that asking the browser and
telling the browser are 2 completely different things.
So that would mean that the rails javascript engine has been written to
handle all the "tell stuff" - but it can't handle the "ask stuff" i.e.
that engine is probably missing.
Could it be that the underlying problem is that the messaging
(responder, initiator sequence) is entirely differnt depending on what
is being done (asking or telling).
I think you're overcomplicating things. Rails generates javascript for
you. It doesn't evaluate it. It has neither a javascript engine, nor
access to all the state of the browser. There isn't any messaging
either, just code generation.
There's some clever stuff going on with RJS, but that's mostly to make
things flow nicely, so that you can write
page[:foo].hide or page[:foo].show
rather than something like
hideElement('foo') or callElementFunction('foo', 'hide')
The trick here is that page[:foo] is not the dom element with id foo.
It's a magic proxy object that knows that when you call hide on it it
should generate $('foo').hide
You could send the javascript back, have the browser evaluate it and
post back a result, but obviously incurs a server round-trip and would
be completely inappropriate for this (not to mention the fact that
that request would be handled by another mongrel etc...)
Fred