Hi!
I have the following code:
var LightIt = {
timeout : null,
highLight : function(elementId){
clearTimeout(this.timeout);
var allpics = 50;
for (var i=0; i < allpics; i++) {
var currentElement = 'pic' + i;
var dummyElement = 'dummy' + i;
if($(elementId).style.opacity == 1){
if(document.getElementById(currentElement) != null) {
if(currentElement != elementId) {
this.timeout = setTimeout(function(){new
Effect.Opacity
(currentElement, {duration:0.2, from:1, to:0.2} )},400);
}
}
if(document.getElementById(dummyElement) != null) {
this.timeout = setTimeout(function(){new
Effect.Opacity
(dummyElement, {duration:0.2, from:1, to:0.2})},400);
}
}
}
},
unhighLight : function(elementId){
if($(elementId).style.opacity == 1){
clearTimeout(this.timeout);
}else{
var allpics = 50;
for (var i=0; i < allpics; i++) {
var currentElement = 'pic' + i;
var dummyElement = 'dummy' + i;
if(document.getElementById(currentElement) != null) {
if(currentElement != elementId)
{
this.timeout =
setTimeout(function(){new Effect.Opacity
( currentElement, {duration:0.2, from:0.2, to:1} )},400);
}
}
if(document.getElementById(dummyElement) != null) {
this.timeout =
setTimeout(function(){new
Effect.Opacity( dummyElement, {duration:0.2, from:0.2, to:1} )},400);
}
}
}
}
}
That code is called by onmouseover="LightIt.highLight('pic1');" and
onmouseout="LightIt.unhighLight('pic1');".
However my Firebug console displays the following error:
"uncaught exception: [object Object]"
I have have figured out that the problem is this part:
this.timeout = setTimeout(function(){new Effect.Opacity
(currentElement, {duration:0.2, from:1, to:0.2} )},400);
The "currentElement" in there seems to be empty, because the value is
not passed to the pseudo function. To see if the script work I did
this:
this.timeout = setTimeout(function(){new Effect.Opacity('pic1',
{duration:0.2, from:1, to:0.2} )},400);
When I directly write the element name into the script it works
perfectly.
The question is, how can I pass the currentElement value to that
pseudo function?
Thanks,
Jan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---