Can Ruby on Rails handle AJAX Response by Static Javascript code? by using RJS?
Posted
by Jian Lin
on Stack Overflow
See other posts from Stack Overflow
or by Jian Lin
Published on 2010-05-24T12:31:17Z
Indexed on
2010/05/24
12:41 UTC
Read the original article
Hit count: 333
So it looks like on RoR, when Ajax (using form_remote_tag) returns a success code, Javascript is also returned to handle the visual effects. (this is the RJS mechanism)
using Fiddler, I do see the following response:
try {
Element.update("vote_score", "Score 58");
$("vote_score").visualEffect("highlight");
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"vote_score\", \"Score 58\");\n$(\"vote_score\").visualEffect(\"highlight\");'); throw e }
Will there be situation where the code is quite big (like 1 or 2k) that RJS can use some sort of static Javascript already loaded to handle the effect?
Is there any other ways to use static Javascript already loaded with the page? Must it be just raw Javascript and use the Prototype's Ajax success response to call the static Javascript code, or can it be some Rails mechanism related to RJS?
© Stack Overflow or respective owner