Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

draggable_element_js returns syntax error when used seperately

#6086

When generating draggable elements from a collection, I'd like to do something like this:

<%= javascript_tag do %>
<%- collection.each do |element| -%>

<%= draggable_element_js "element_#{element.id}" %>

<%- end -%> <% end %>

However, this returns the following javascript which results in a syntax error:

new Draggable(& quot;element_6& quot;, {revert:true});

NB: I edited the above, there's no space between the & and quot;, but your browser might translate it to " otherwise.

It works when you do the iteration outside of the javascript_tag, but the point of using draggable_element_js is that it won't generate a javascript tag for every element. I prefer that.

I now fix this by doing this:
..

<%= raw draggable_element_js "element_#{element.id}" %>

..

I'm not sure what the expected behaviour is for this method. If it's only meant to be used inside the javascript_tag method and not in an iteration, that should be documented somewhere. My solution feels like a workaround, not expected behaviour.

Reported by Jaap Haagmans · November 29th, 2010 @ 09:14 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. rails
    rails
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    March 1st, 2011 @ 12:00 AM

  2. rails
    rails
    • State changed from open to stale

    March 1st, 2011 @ 12:00 AM