Help Fading in/out request response

0 views
Skip to first unread message

donakeiko

unread,
Aug 26, 2008, 2:36:38 PM8/26/08
to MooTools Users
Guys,

I'm trying to add a simple effect to a div loaded with Request.HTML.
When the request is made, I want the div to fade out and only after
the response is completely loaded I want it to fade in. I came up with
this:

var menuSabores = $$('a.mini');
menuSabores.each(function(element) {
element.addEvent('click', function(event) {
event.stop();
embalagem.fade('out');
var req = new Request.HTML({
url: element.get('href'),
method: 'get',
update: embalagem,
onComplete: function() {
embalagem.fade('in');
},
onFailure: function() {
embalagem.set('text', 'Erro ao carregar o produto');
}
}).send();
$$('a.mini').removeClass('ativa');
element.addClass('ativa');
});
});

We see it fade out and then we see it loading, we can't see it fading
in. I tried with chain also but it didn't work as well. I think that
maybe the fade in must be chained after Complete event, but I don't
know how to write it.
could somebody help me please?
Thanks,
Cátia

ScottBruin

unread,
Aug 29, 2008, 6:49:52 PM8/29/08
to MooTools Users
I usually do something like below. Not sure how "correct" it is but
works for me.

var ChainClass = new Clas({ Implements: Chain }); var c = new
ChainClass();

c.chain(
function() { /* request - oncomplete: c.callChain() */ },
function() { /* item.fade('in') */ }
);

c.callChain();
Reply all
Reply to author
Forward
0 new messages