ruby on rails - Use a hash to map to element id's with jQuery -
i have form want put submitted data correct form inputs. have hash keys id selector of form input , value the value specific form input.
this hash looks like:
@saved_answers = {"123456"=>"tom", "2345678"=>"brady", "789456"=>"football"}
i passing hash used in jquery
# found in view's script var form_saved_answers = '<%= @saved_answers.to_json %>';
now when in javascript file, want find input id key , place value in input field.
this stuck, i've thought making each key/value pair array , run each function... there has more direct approach...
any ideas?
do without '
char var form_saved_answers = <%= @saved_answers.to_json %>;
can form_saved_answers['123456']
if key not number can form_saved_answers.some_key
Comments
Post a Comment