Forum: Ruby on Rails RJS in a callback

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Andy (Guest)
on 2007-07-06 15: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.

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

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