Created
January 9, 2022 21:44
-
-
Save wrburgess/4a139eb6cffbab1c7ae3a0a8be2d4f2b to your computer and use it in GitHub Desktop.
Rails erb view embed json in html and retrieve with JS dom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const widgetsData = document.querySelector('.widgets-data'); | |
const widgets = JSON.parse(widgetsData.value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data class="widgets-data" value='<%= @widgets_json.html_safe %></data> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment