using Array.each in a helper

hi all,

I'm trying to do a each on an array the droppable element
<%= draggable_element "user_" + create_drop_zone(zone),
                                    :revert => true,
                                    :onStart => "function(){" %>
                                        <% drop_zone_ids.each do |
zone> %>
                                            Element.addClassName('<%=
zone %>', 'border');
                                        <% end %>
                                        Element.addClassName('user_<%=
user_node %>', 'move_user'); }

This results in:
//<![CDATA[
new Draggable("user_1_4", {onStart:function(){, revert:true})
//]]>
</script>
Element.addClassName('3', 'border');
Element.addClassName('4', 'border');
Element.addClassName('user_1_4', 'move_user'); }

Someone knows how to solve this?

thanks
Stijn

Hi --

hi all,

I'm trying to do a each on an array the droppable element
<%= draggable_element "user_" + create_drop_zone(zone),
                                   :revert => true,
                                   :onStart => "function(){" %>
                                       <% drop_zone_ids.each do |
zone> %>
                                           Element.addClassName('<%=
zone %>', 'border');
                                       <% end %>
                                       Element.addClassName('user_<%=
user_node %>', 'move_user'); }

This results in:
//<![CDATA[
new Draggable("user_1_4", {onStart:function(){, revert:true})
//]]>
</script>
Element.addClassName('3', 'border');
Element.addClassName('4', 'border');
Element.addClassName('user_1_4', 'move_user'); }

You need to drop down to regular Ruby string interpolation. Try this:

  <%= draggable_element "user_" + create_drop_zone(zone),
       :revert => true,
       :onStart => "function(){#{
          drop_zone_ids.map do |zone|
            "Element.addClassName('#{zone}', 'border');
            Element.addClassName('user_#{user_node}', 'move_user');
            "
          end}
          }" %>

David