How to pass javascript variables to rails variables -
how can pass javascript variable ruby. want don't know how express it.
function save(){ var g = document.getelementbyid("self").value; <% @owner.info = g %> }
another possible work around need able extract contents of text area through rails , not javascript.
can me?
what attempting doesn't make sense vanilla rails installation , javascript. here's workflow accomplishes you're trying along details:
1. page requested server
the ruby code runs rails , application executed on server. server receives request, executes ruby code, , sends response html document.
2. user gets response server
the user's browser receives html , turns pretty web page. it's @ point javascript related application executed in user's browser. connection server has been severed , no further ruby code executed until request made.
3. user fills out ajax form
on page rendered in step 2, have form. following this guide can tell form submit via ajax. means instead of requesting new web page, browser send special request using javascript server. server can save form values database , send response browser. while user hasn't left page viewing.
alternatively can skip ajax , have user submit form, you'll need redirect them page viewing (and adding note form submitted saved).
Comments
Post a Comment