I would really appreciate some help with changing a link_to_remote call
to a button of some sort. Here’s a little background.
On the page there are two
s. One is a form that lets the visitor
enter items. The second
is where the entered items get displayed,
each in it’s own item
.
Each item
has two s. The first one displays the item
description as entered in the form. The second contains a
link_to_remote that allows the removal of the item from the database in
the controller action and then removal of the item
from the page
using RJS.
As I understand the discussion in AWDwR (p. 335-7), a visitor who has
the Google Web Accelerator (GWA) installed is going to have a real
problem unless I change the link_to_remote to a button. As I
understand it, every time they add an item, GWA is going to follow that
link and remove what they just added.
First, can anybody confirm (or even better, correct my understanding)
that that’s the way GWA is going to work?
Second, assuming I’ve got a real problem, has anybody got any ideas
about how to make this change? I’ve experimented a bit and the
situation right now, using button_to, is that the controller gets called
and the database record gets deleted. When the RJS template gets
called, however, and sends the JS to the browser to remove the item
from the page, instead of executing the JS, the browser intercepts
it and asks if I want to save it. I don't understand why or what I need
to do to make this change work.
I would really appreciate some help with changing a
link_to_remote call to a button of some sort.
have you tried wrapping your button in a form_remote_tag?
No I haven’t. And I’m not sure I understand the suggestion. Do you
mean
wrapping or replacing? If I could wrap it, which I don’t think I can
since,
AFAIK, I can’t have a form within a form, it seems like that would give
me
two buttons. OTOH, I’ll take a look at the syntax for form_remote_tag
and
see if that might work. Thanks for the suggestion!
If you are placing the button into the form then I’m not sure that you
can
put another form just around the button.
I’m guessing a bit here but I think you should be able to use the
remote_function method to get a remote function attached to the button,
this
is basically the same as a link_to_remote call