Forum: Ruby on Rails RJS in a callback

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.
820998d915f73a9db16cac535aee5a99?d=identicon&s=25 Andy (Guest)
on 2007-07-06 13:04
I'm trying to use RJS to construct javascript for an :onDrop callback.

Here's the code. Fun stuff is the RJS after the :onDrop.

<%= drop_receiving_element :dropAccept, :accept => 'dragclass' ,
          :onDrop => update_page {|page|page.alert 'no postback'} %>


This results in the following javascript which throws a syntax error.

//<![CDATA[
Droppables.add("dropAccept", {accept:'dragclass', onDrop:try {
alert("no postback");
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('alert(\"no
postback\");'); throw e }})
//]]>


Anyone have any ideas why?

Many thanks in advance
Andy


Ps. Pretty sure the problem is RJS, since a vanilla JS callback like
below...works fine.
:onDrop => "function(drag, drop){ alert('you droped ' + drag.id + ' on '
+ drop.id) }"
This topic is locked and can not be replied to.