Is there a way to assign a CSS style to an element I am not currently
interacting with? For instance, if I have two TD elements of a table. I
click on one of them, and I want to have a style change in the other
element. Is this possible?
I’m guessing script.aculo.us might be able to help me… but
considering how nothing on their site is loading for me right now I have
no way of looking through their WIKI.
Let’s assume the text will be hyperlinked. Yes, you’ll probably want
to use scriptaculous or something similar. The hyperlinked text in
the td will be using a link_to_remote method call. You’ll need to id
each of your id’s or use some other method of identifying them. In
the link_to_remote, pass in some information to the controller that
will let you know which one you clicked on. Alternatively call a
separate method for each link_to_remote.
In the call to your controller you’re going to want to use render
:update do |page| block or use an RJS for rendering. I would just do
it inline since the changes are minor. For the actual change, look
into using prototypes Element.addClassName method.
http://wiki.script.aculo.us/scriptaculous/show/Element.addClassName
Alternatively, if you just want to simplify, just review the
referenced prototype page and use it inline like they are doing it.
The example there is exactly what you want.
Michael
On 25 May 2006, at 05:57, Michael T. wrote:
it inline since the changes are minor. For the actual change, look
into using prototypes Element.addClassName method.
http://wiki.script.aculo.us/scriptaculous/show/Element.addClassName
Alternatively, if you just want to simplify, just review the
referenced prototype page and use it inline like they are doing it.
The example there is exactly what you want.
I’m broadening the original question somewhat: what would be the most
effective way to implement selection in alternating rows tables?
So basically, you have one with class ‘selected’, you click on a
different row, then the first gets his empty or ‘odd’ class back
(depending on what color the row should have as it’s alternating) and
the clicked row gets the ‘selected’ class.
Currently, I’m storing the selected row id in a session, looping
through all s of the table just to change 2 rows seems very
ineffective to me.
Anyone have a better and cleaner idea on how to do this? (as a test,
use a table with about 500 rows in it, for performance comparison)
Best regards
Peter De Berdt
Have no idea if this will work, didn’t test it.
But, something like this could work w/ prototype 1.5.
ok. that didnt work. but this does:
ok. that didn’t work.
but this does:
Now the big question is: how performant is it with a huge number of
rows. One of these days, I’m going to test it.
On 26 May 2006, at 20:37, David C. wrote:
$$('#myTable tr').each(function(e) {
assignClickEvents();
//–>
Best regards
Peter De Berdt