Reputation: 3057
I have a @coords
variable:
#maps controller
def index
@coords = Map.all
end
Inside index.html.erb, I have:
<%= content_tag 'div', id: 'coords', data: @coords.to_json do %>
<% end %>
How my content_tag looks like after rendering HTML page:
[{"id":1,"vibration_level":456,"lat":"71.45543","lon":"53.43424","time_sent":"1994-05-20T00:00:00.000Z","created_at":"2015-06-13T06:53:30.789Z","updated_at":"2015-06-13T06:53:30.789Z"} ]
How can I access it from a JavaScript file.
Upvotes: 0
Views: 59