Forum: Ruby on Rails Javascript Troubles

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.
5190330ad8f1b06d35e2c2da73dc623c?d=identicon&s=25 eric (Guest)
on 2005-11-14 03:38
(Received via mailing list)
I'm have some troubles with some javascript that is being generated. I
have the following in my view.

<%=link_to_remote(image_tag('delete.gif'),
	:update => {
		:success => update_element_function(
			"name_#{@child.id}",
			:action => :remove)
	},
	:url => {
		:action => "delete_category",
		:id => @child.id
	})%>

So we have a link_to_remote() function that calls a action and then
remove a bit of HTML on success. Seems fairly harmless. But the
following is generated:

<a href="#" onclick="new
Ajax.Updater({success:'Element.remove('name_126');
'}, '/business/delete_category/126', {asynchronous:true,
evalScripts:true}); return false;"><img alt="Delete"
src="/images/delete.gif" /></a>

As you can see the success code has single quotes in it but the success
code is in a single quote itself. This causes a syntax error. Any
suggestions?

Eric
This topic is locked and can not be replied to.