thanks for taking the time to answer bill, my post was indeed vague i
must reckon, i’ll try to clear things up.
bill walton wrote:
For starters, what’s a ‘system component’? And whatever it is, is this
the thing that you want go get loaded when the user takes some action?
well it’s actually a 3d game engine plugin (s3dplayer from
www.stonetrip.com FYI), so it’s actually a system-wide component taht
relies on a JS to be loaded into the browser on page load.
Once loaded it should remain on the page, the user interacts with it,
and under certain circumstances, it will fire up JS functions to update
elements of the DOM.
On defined user actions,
So we’re talking about clicking a link or a button?
Well no, and that’s the tricky part, thanks for pointing this out.
The ‘triggering’ action would actually come from the user interacting
with the game engine component, as i explained.
The component can access the system to open a URL, so I use this to call
JS functions, with _self as the target, so the page doesn’t reload.
this component will call a definable JS method,
Definable? As in ‘not known until run-time’?
Well sort of (cf. my previous response), and that’s precisely where i
get confused.
When using link_to_function, rails knows about an actual element that
will act as a trigger (form field, some text etc), here the triggers are
just function calls to the JS layer of the client.
that i’d like to act in a link_remote_to fashion, to update some
elements of the page.
link_to_remote(…) makes an XHR / XMLHttpRequest to a controller method
on the server. In Rails you have several options WRT constructing the
JS response the client expects. The easiest is an RJS template that
replaces existing html element(s) on the page.
I highly recommend Cody F.'s O’Reilly Shortcut: RJS Templates. Best
$10 I’ve spent on Rails so far.
link_to_function(…) calls a JS function you specify in the call.
Well, I’d really like to be able to specify some DOM behavior as soon as
the triggering user-action takes place (like displaying a spinner
without relying on a JS callback), that’s what i meant by
“link_to_function fashion”, i’m thinking i might have overlooked the
traditionnal routes way though…
hope this makes more sense.
cheers