views:

723

answers:

2

I'm ultimately trying to delay the fade out by 5 seconds (page loads, 5 seconds later the fade out happens). But right now the bit of code below throwing a "delay is not a function" error.

el.fade('out').get('tween').chain(function(){
    el.destroy();
}).delay(5000);
+1  A: 

Delay is a function method, this should work:

el.fade('out').get('tween').chain(function(){
    el.destroy();
}.delay(5000));
Rob
No go. Error from firebug: this.$chain.shift().apply is not a function
Shpigford
Hmm not sure on that, I suppose you could just go with: setTimeout(function() { /* code */ }, 5000);
Rob
`.delay()` has to be added to a function, in this case encapsulate the code inside an anonymous function that's enclosed in parens - like this: `(function(){ /* your code goes into this block */ }).delay(5000)`
artlung
so he's missing a ) after } and before .delay. still - this IS the better reply as it insures continuity and that the el won't be removed before the tween is over.
Dimitar Christoff
+4  A: 

This works where el is a valid element. I used an item with id of demoitem to test it, so:

var el = $('demoitem');
(function(){
 el.fade('out').get('tween');
 el.destroy();
}).delay(5000);

delay() is a function which is can be chained to functions, not to the chain of an HTMLElement.

artlung
Thank you for this, it's helped me in a very tight spot, with a deadline looming :D
phalacee