AJAX mootools Fx.Tween problem
I wrote a piece of code which would simply allow a gradual change in color of a link during the passage of the mouse. But nothing happens gives me an error.
My piece of code,
HTML Code:
<html>
<head>
<script type= "text/javascript" src= "mootools-1.2.1-core-nc.js"> </script>
<script type= "text/javascript" >
window. addEvent ( 'domready', function () {
var list = $$ ( 'a');
list. each (function (element) {
var fx = new Fx. Tween ( element, { duration: 500 , wait: false } ) ;
element. addEvents ({
'mouseenter' : function ( ) {
fx. start ({'color': '#999'});
},
'mouseout': function () {
fx. start ({'color': '# 000'});
}
});
});
});
</script>
</head>
<body>
<a href= "http://google.co.in">Google </a>
</body>
</html>
If I remove the code fx.start (...) and replace it by an alert (element), the error message disappears and I can see the window alert () in the URL.
If someone has an idea ...
Re: AJAX mootools Fx.Tween problem
I have a doubt about the syntax of your dict (lines 11 and 14):
Try
fx.start({ color : '#xxx' });
without quotes around 'color'
Re: AJAX mootools Fx.Tween problem
I do not know about mootools and I do not have much time to watch your stuff, but in general tips when you do JS: install firebug (Firefox extension), and instead to alert (foobar), do console.log (foobar), it allows you to log objects and see all their values, properties etc..
Re: AJAX mootools Fx.Tween problem
have you tried this:
Code:
fx.start ( 'color': '#999');
If you did not specify what property you are going to change (here, color) in the constructor, then you must necessarily pass this property as the first argument to the call to start ().
Re: AJAX mootools Fx.Tween problem
Well, it was almost, it was not to pass a dict fx.start (), but direct ownership
replace
Code:
fx. start ( { 'color' : '#xxx' } ) ;
by
Code:
fx. start ( 'color' , '#xxx' ) ;
with "," to separate and not ":"
Everything is now normal, thanks anyways.