javascript inside html-erb files issue

anniesangelny

New Member
I ma trying to understand why this javascript inside my erb file is not working \[code\]<%= javascript_tag do %> var tmp= "<%=j render :partial => "layouts/alert_error_message", :object=>@campaign %>";<% end %>\[/code\]I get this message\[code\]compile error/var/www/gitorious/app/views/campaigns/new.html.erb:32: syntax error, unexpected ')'...r.concat(( javascript_tag do ).to_s); @output_buffer.concat .../var/www/gitorious/app/views/campaigns/new.html.erb:38: syntax error, unexpected kENSURE, expecting ')'\[/code\]When I use instead \[code\]<% javascript_tag do %>\[/code\], the render method is correctly processed but the tmp variable is not set in my javascript (\[code\]console.log(tmp)\[/code\] returns \[code\]undefined\[/code\]) Edit : I wrapped the render method with \[code\]escape_javascript\[/code\] and it worked but I still don't undestand why it is only working when I use \[code\]<% javascript_tag do %>\[/code\]. Is it not suppose to work with \[code\]<%= javascript_tag do %>\[/code\] ?
 
Back
Top