This project is archived and is in readonly mode.
draggable_element_js returns syntax error when used seperately
Reported by Jaap Haagmans | November 29th, 2010 @ 09:14 PM
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.
Comments and changes to this ticket
-
rails March 1st, 2011 @ 12:00 AM
- 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.
-
rails March 1st, 2011 @ 12:00 AM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>