I have autofill.js.erb
file in which should change value of input field with id request_mobile
to @client.mobile
, where @client.mobile
is defined in autofill method. So i guess it should be accessible in autofill.js.erb
file. both files are in one view folder.
$("#request_mobile").val("<%= escape_javascript @client.mobile %>");
But what i get is:
$("#request_mobile").val("");
So my ruby is not embedded int JS or something like that. What is the proper way of writing js.erb
files.
Also trying :
$("#request_mobile").val("<%= @client.mobile %>");
doesn't help
@client.mobile
in this instance?""
in the output. You would see the original string of Ruby source code between<%=
and%>
. At this point, it's pretty clearly a case of@client.mobile
not containing what you think it contains.