*To apply a script after page loaded (all dom node loaded)*
document.observe('dom:loaded', function() {
$$('tr.lignealternative').each(function(elmt) {
elmt.observe('mouseover', function(ev) {
elmt.toggleClassName("lignehover");
});
elmt.observe('mouseout', function(ev) {
elmt.toggleClassName("lignealternative");
});
});
});
*To apply a script after an ajax response:*
new Ajax.Request(url, {
onSuccess: function(transport) {
$$('tr.lignealternative').each(function(elmt) {
elmt.observe('mouseover', function(ev) {
elmt.toggleClassName("lignehover");
});
elmt.observe('mouseout', function(ev) {
elmt.toggleClassName("lignealternative");
});
});
}
});
On Thu, Mar 18, 2010 at 4:46 AM, Joannes De KOSTER <
[email protected]> wrote:
> Hello,
>
> How can i apply a script on an html element (for example a table) when
> this element is loaded in the page afterwards (after ajax request)?
>
> This code never gets to work for example :
>
>
>
> $$('tr.lignealternative').each(function(elmt) {
> elmt.observe('mouseover', function(ev) {
> elmt.toggleClassName("lignehover");
> });
> elmt.observe('mouseout', function(ev) {
> elmt.toggleClassName("lignealternative");
> });
> });
>
> Because the table gets loaded after an ajax request, when the page is
> already loaded.
>
> Thanks.
>
> Joannes
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<prototype-scriptaculous%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.