javascript - escaping when passing a variable to the data option -


i trying enter rails variable in data option code not work expected. html , javascript escaping didn't work me.

the code:

<% @fields = render(partial: 'participations_fields', locals: {f: f})%>       #its part of form      <%= link_to_function("addy","addy()",      data: {try:@try, content: @fields}, id: "try")%> 

the participation_fields partial:

<p>hello</p> <%= f.label(:name,"feast name")%><br /><br /> <%= f.text_field(:name) %> <br /><br /> 

the code not work expected. get:

feast name  #here text input field#  #this showed on screen:# " data-try="10" href="#" id="try" onclick="addy(); return false;">addy   

escape_javascript , h() didn't work.

how should escape code variable go content data? if put html rails generates this:

<%= link_to_function("addy","addy()",       data: {try:@try, content: '<p>hello</p>      <label for="feast_name">feast name</label>      <br><br>      <input id="feast_name" name="feast[name]" type="text" value="has no name">      <br><br>      '}, id: 'try')%>    

this works fine.

how should escape it?


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -