Handling dynamic data from javascript or rails
Posted
by 99miles
on Stack Overflow
See other posts from Stack Overflow
or by 99miles
Published on 2010-04-14T03:44:58Z
Indexed on
2010/04/14
4:03 UTC
Read the original article
Hit count: 325
ruby-on-rails
|JavaScript
I have page consisting of a calendar view ( http://code.google.com/p/calendardateselect/ ) as well as divs, each of which contain information about a person. In each div I want to have a link to a new controller and action, and pass the id for the person and the date selected in the calendar.
I can think of a one way, but I'm thinking there's likely a better solution:
1) Do something like:
=link_to_function "Week", "weekClicked(#{person.id})"
Then in the weekClicked() javascript method I get the selected date from the calendar, such as:
$('e_date').selected_date;
then with javascript I could make a post request as mentioned here: http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
2) Or, is there a way that I could make each link a button in it's own form and maybe have a hidden field that gets the selected date from the calendar as or before the form is submitted? I tried this too, but couldn't figure it out. This definitely seems like it's more on the right track than #1.
Thanks.
© Stack Overflow or respective owner