Forum: Ruby on Rails JRS problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marc (Guest)
on 2006-04-25 23:05
Hi all,

I'm playing with the new RJS stuff. Very cool!

But I have a problem. The following code works ok:

page.select('div.blogcomment').each do |element|
  page.visual_effect :highlight, element
end

All div's with class blogcomment are highlighted correctly. But I just
want the last elemen to be hightlighted. The following code is not
working:

page.visual_effect :highlight, page.select('div.blogcomment').last

Instead of highlighting the last item the generated javascript is
visible on the page.

Do I mis something here?
Alex W. (Guest)
on 2006-04-25 23:22
Marc wrote:
> The following code is not
> working:
>
> page.visual_effect :highlight, page.select('div.blogcomment').last
>
> Instead of highlighting the last item the generated javascript is
> visible on the page.
>
> Do I mis something here?

What javascript is generated?
Marc (Guest)
on 2006-04-25 23:29
Alex W. wrote:
> What javascript is generated?

try { Form.reset("comments_form"); Element.replace("comments", "
\n \n
Reacties
\n \n\t
\n\t\t
reactie van sdfa op 25-04-2006 21:27
\n\t\t
dsfdsaf
\n\t
\n\t\n\t
\n\t\t
reactie van dsf op 25-04-2006 21:27
\n\t\t
sdfsdaf
\n\t
\n\t\n\t
\n\t\t
reactie van sdf op 25-04-2006 21:28
\n\t\t
sdfdsf
\n\t
\n\t\n \t\n
\n"); $$("div.blogcomment").last().toJson().toS(); new
Effect.Highlight(#,{}); } catch (e) { alert('RJS error:\n\n' +
e.toString());
alert('Form.reset(\"comments_form\");\nElement.replace(\"comments\", \"
\n \n
Reacties
\n \n\t
\n\t\t
reactie van sdfa op 25-04-2006 21:27
\n\t\t
dsfdsaf
\n\t
\n\t\n\t
\n\t\t
reactie van dsf op 25-04-2006 21:27
\n\t\t
sdfsdaf
\n\t
\n\t\n\t
\n\t\t
reactie van sdf op 25-04-2006 21:28
\n\t\t
sdfdsf
\n\t
\n\t\n \t\n
\n\");\n$$(\"div.blogcomment\").last().toJson().toS();\nnew
Effect.Highlight(#,{});'); throw e }
This topic is locked and can not be replied to.