Thiago,
I am most impressed with Prototype. I really like using $$(). Here's my code to add onmouseover, onmouseout and onclick handlers for a zebra striped table. Unfortunately, I have to support IE6, so I couldn't use :hover for the mouse over/out handlers.

Tapestry.onDOMLoaded(function() {
    var mouseover = function(e) {
        this.className = 'DataTableEntryMouseOver';
    };

    var click = function(e) {
// This location is sadly hardwired into the code - not very nice :-( window.location.href='/onlinebanking-biwvp/CustomerSearch.customerId/' + this.cells[1].textContent;
    };

    $$('#customerTable tbody tr.DataTableEntryEven').each(function(elmt) {
        Event.observe(elmt, 'mouseover', mouseover);
        Event.observe(elmt, 'mouseout', function(ev) {
            this.className = 'DataTableEntryEven';
        });
        Event.observe(elmt, 'click', click);
    });

    $$('#customerTable tbody tr.DataTableEntryOdd').each(function(elmt) {
        Event.observe(elmt, 'mouseover', mouseover);
        Event.observe(elmt, 'mouseout', function(ev) {
            this.className = 'DataTableEntryOdd';
        });
        Event.observe(elmt, 'click', click);
    });
});

Hope this helps the next person!
Jonathan

On 09/02/2009 18:52, Thiago H. de Paula Figueiredo wrote:
Em Mon, 09 Feb 2009 14:40:33 -0300, Jonathan O'Connor <ninki...@eircom.net> escreveu:

Thiago,
The mouse out and over handlers change the background color, as the user moves teh mouse over the table.

This can be done in CSS using the :hover pseudo-selector.

I also need to set the onclick of each td so it goes to a new page. I'll have a look at doing it the prototype way :-(. I suppose it really is the proper way to that.

That really needs Javascript, and it can be easily done with Prototype. I have almost no experience and I was able to do some DOM operations with Prototype in a short time frame. ;)

I had another idea, that I could modify the DOM tree after rendering (say in cleanupRender) but I haven't seen any examples do this.

A very nice place to learn how to deal with Javascript issues in Tapestry is http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to