Mapping X-Y Coordinates from rails iteration
I've created a photo tagging system using jQuery, however once I refresh the page the tags do not show up. I created an erb iteration that goes through all the tags and finds the x-y coordinates but I'm stuck on how to display them.
- <% @image.each do |image| %>
- <%= image.connections.each do |conn| %>
- <span class="connection" data-pos-x="<%= conn.pos_x %>"></span>
- <span class="connection" data-pos-y="<%= conn.pos_y %>"></span>
- <% end %>
Which returns something similar to:
- <span class="connection" data-pos-x="<%= conn.pos_x %>"></span>
- <span class="connection" data-pos-y="<%= conn.pos_y %>"></span>
So i'm wondering how I can cycle through all the connections (I think a for loop) and then plot their coordinates on to the image field. Here is the link to the
jsFiddle
with the working photo tagger. Any help would be greatly appreciated!