On 2-Mar-07, at 10:54 PM, Wai T. wrote:
seems to work pretty well - you’ll just have the same onclick JS
you.
Actually, after some researching, I found that it is possible to have
onmouseover events for TR cells. Now, the problem is how to do that
elegantly (with AJAX?) to pass parameters back to the controller.
My idea would be to have a hidden text fields or check box for each
table row, that will get toggled. But storing the values in hidden
text
fields seems like a hack. Does anyone have a better idea?
Wai,
<tr class="<%= row_class %>"
onmouseover=“this.className=‘selected’” onmouseout=“this.className=‘<%
= row_class %>’” style=“height: 45px;”>
the above will handle the highlighting requirement for each row -
where row_class is the ‘normal’ not highlighted class - and
‘selected’ is the class for a highlighted row.
erb is assigning a row_class for me, as I want to alternate the
colors for each row. This can be accomplished by iterating over your
detail records and assigning an alternating row class:
<%
@work_order_items.each_with_index do |line_item, line_count|
row_class = line_count%2 == 0 ? “even” : “odd” #note there is
a helper provided by rails to do this - can’t remember the helper name
%>
as for ‘hotlinking’ you’ll need to have each cell (td) call some
javascript. You haven’t said what you want to hotlink, but I can
assume you’re thinking of an ajax action - take a look at
remote_function in the api docs, using the (undocumented?) :with
parameter ala:
'your_row_id', url =>
'your url', :id => @line_item.id %>"> @line_item.description
that should be enough detail to you get you started. Rails helpers
aren’t an excuse for not knowing javascript - you really need to pick
up this skill - plus CSS. Rails (imo) makes it a bit easier to deal
with these topics, but you’re inevitably going to find yourself in
circumstances where you’re gonna get just plain lost. Use view source
to see what the helpers do for you, and grab [1]firebug to help debug
when things aren’t going well.
you’re on your own now cowboy - enjoy the ride!
Jodi
[1] Redirect Notice
2Faddons.mozilla.org%2Ffirefox%2F1843%
2F&ei=Ra3pRYfhNZX0iAHN24CjBw&usg=__Wnv_futN3OoTeIAOWgVEsUSVydk=&sig2=nv9
Hrc3RmImQuzWGlGjTXw