javascript - Rails3: change content of table column on mouseover -


given simple view table:

        <% entries.each |entry| %>             <tr>                 <td class="align-left"><%= entry.date.strftime("%d.%m.%y") %></td>                 <td class="align-right><%= my_number_to_currency entry.amount_calc %></td>                 <td class="align-left"><%= entry.description %></td>                 <td class="align-left"><%= entry.tag %></td>             </tr>            <% end %>    

i want change content of second column (for every entry) my_number_to_currency entry.amount @ runtime on mouseover , change original value when mouse leaves again. in addition, want add style, either class="over" or directly set color of element.

i'd grateful pointers how best achieved in rails3 (and put code if needed in 1 view).

(remarks: my_number_to_currency simple helper, think of normal number_to_currency , added jquery-tag use auto-complete , therefore available if helpful solution)

update

i tried following in application.js success:

$(document).ready(function() {     $(".joint").hover(         function() { $(this).children(".full").show(); $(this).children(".half").hide(); },         function() { $(this).children(".half").show(); $(this).children(".full").hide(); }     ); }); 

this might not you're looking for, in position...

i supply both default , mouse-over values <td>, , use jquery hide() , show() hide , reveal value. way, information available whether or not user has javascript enabled (ie progressive enhancement). reduces number of server calls required constant mouse movement.

be sure tie in event (rather mouse-over) effect, tablets, ipads, iphone, , other devices not have hover capability.

it sounds want can (and should) accomplished purely jquery/javascript. if you're new jquery, documentation rocks.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -