I have a JS Fiddle
I want to interpolate a small javascript script as text on a rails .erb view.
i want to take the input element from the js fiddle and store the javascript string as the value of the input element so that I can use the fiddle to copy the script into the clipboard.
The catch is this... I want to be able to interpolate some values into the string. ie
"function() {var arr = [<%= @rails_value %>]}"
Below is the code in which ruby data pass in js variable and add data to html page.
<div class="test"></div>
<script type="text/javascript">
add_text()
function add_text(){
var value = '<%= @rails_value %>'
$(".test").html(value)
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.