I’m building an application for a touchscreen that pages through a set
of survey pages. On each page, the user makes some choices by touching
items on the screen (words, or images) and, when satisfied with their
choices, clicks the Next page button.
Rails has done a great job helping me get things to the screen, and
paginating for me… but I’m stuck on something that I’ve implemented
before in plain old javascript:
When a user touches an item, in the old days I would simply write a
string to the end of the window.location.href:
function addThisToo(key, value)
{
window.location.href += “&” + key + “=” + value
}
and, at some point later on, submit this, and there you go…
My experience with Rails, so far, has been that there are remarkably
sensible solutions for many of web work’s little problems… is there a
Rails solution for this one? (My preference is for a non-AJAX solution
at this point…)
I’m building an application for a touchscreen that pages through a set
of survey pages. On each page, the user makes some choices by touching
items on the screen (words, or images) and, when satisfied with their
choices, clicks the Next page button.
Rails has done a great job helping me get things to the screen, and
paginating for me… but I’m stuck on something that I’ve implemented
before in plain old javascript:
When a user touches an item, in the old days I would simply write a
string to the end of the window.location.href:
function addThisToo(key, value)
{
window.location.href += “&” + key + “=” + value
}
and, at some point later on, submit this, and there you go…
My experience with Rails, so far, has been that there are remarkably
sensible solutions for many of web work’s little problems… is there a
Rails solution for this one? (My preference is for a non-AJAX solution
at this point…)
thanks to all
-Bill
You can add custom parameters to links like this…
link_to “Do Not Push!”, {:controller=>‘world’, :action=>‘rotation’,
:speed=>“stop”}, :post=>true, :confirm=>“Are you sure? There is no
Undo!”
In addition to this (good) suggestion, you can use named routes and
routing variables to make this cleaner. http://wiki.rubyonrails.org/rails/pages/NamedRoutes
The above would then be:
link_to “Do Not Push”, stop_button_url(:speed => ‘stop’, :post =>
true, :confirm => “Are you sure?”)
…which lets you omit the :action and :controller options.
The link_to will fix the link at render time. AJAX would be an easy way
to do what you want, just have it observe the fields the user can change
and have it update the link as needed.
_Kevin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.