On Mar 8, 2011, at 11:14 PM, slava wrote:
> Having problems rendering javascript in erb file. Thanks for
> suggestions.
>
> //layout erb file
> (function() {
>
> ...
> var widget_properties = {};
> <%= content_for?(:extend_widget) ? "widget_properties = " +
> yield(:extend_widget) : '''' %>
> ...
> })();
>
>
> //view erb file
> <% content_for :extend_widget do %>
> extend = {
> _init: function() {
> $("input[type=''checkbox'']",
this).live(''click'', function() {
> ...
> });
> }
> }
>
> <% end %>
>
> //resulting script - notice the " instead of " in code below
> (function() {
> ...
> widget_properties = extend = {
> _init: function() {
> $("input[type=''checkbox'']",
this).live(''click'',
> function() {
> ...
>
Rails 3 erb applies h() to most strings automatically. Instead of
having to remember to apply h, you have to remember to mark the
strings you want to be left alone as html_safe or raw. I don''t know
the precise syntax to use in your case, but that''s where I would start
looking.
Walter
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.