State changing click on divs

I’ve moving on from the data collection part of my app to the data
manipulation part and I’m at loss how to proceed, whether I need to put
asside my rails booka and learn some java or not.

I will have a view that iterates through a collection of objects then in
turn increments another variable to create a series of div elements with
content related to the object and increment. For example Objects [A…E]
, Increments [1…3] yieldsing 15 div’s A1, A2, A3, B1, B2, B3, C1 …

In those divs I will be diplaying images and data based on data in the
object attibutes and the interator.

I would like the entire

clickable, not a button within the div. I
want to call a controller method and pass at least the object_id (of
A-E) and the iterator (1-3 in this example). If a button were
acceptable, I think i could have a form with two hidden fields passing
the necessary information in params.

As clicking will call a method which will make changes to the database a
form with a true post might have some advantages(from what i fuzzily
understand)).

I am sorry if this question is very basic… and perhaps not even a
reils question…although I am interested in the rails best practices
solution if there are many solutions.

Do I build a div with some sort of " onclick " that can push an
“invisible??” button within the div containing hidden fields?

Is there a rails helper that will wrap a div to make it clickable and
which I can load with a couple parameters and will that be safe if the
method called will make changes to my database?

in plain english, if I were in the second div A2.
If anywhere in this div is clickced, call method change_user_records
with letter_id = A.id , number = 2

I know that isn’t anywhere close to code but it explains the simple
thing I hope to do and don’t know which tool to turn to.

On Dec 16, 12:24 am, Tom N. [email protected]
wrote:

method called will make changes to my database?

If you want to do this with ajax, use remote_function(). If not you
could mess with link_to. This has an option which will cause it to
generate a link with an onclick which will dynamically create a form
with the appropriate fields and submit it. I’m sure you can work out
from the source for link_to how to do this yourself

You could also create the forms, but have no form submit buttons. In
which case your onclicks are just $(‘form_id’).submit()

Fred.

You could also create the forms, but have no form submit buttons. In
which case your onclicks are just $(‘form_id’).submit()

Fred.

Thanks for the advice yesterday… I finally got it using method number
three!

Hoorah! I’ll post the example for other struggling newbies in a day or
so.(my coding machine is offline). There were a couple gotchas with
setting the id’s for the form.

Now I need to start figuring out the default mouse tips, hover diplays
and div css stuff to give users a clue that they can actually click on
the given divs!

I also wonder what percentage of internet users the “onclick” stuff
works for…
; )