回调中的回调? [英] Callback in a callback?
问题描述
我这样写了一个回调(我相信它被称为)
I wrote a callback (I believe it's called) like this:
hugeFadeIn();
这是一个用于淡入某些内容的简单代码,这样我就不会一遍又一遍地重复使用相同的代码.
It's a simple code to fade in some content so that I don't reuse the same code over and over again.
然后我想在hugeFadeIn
完成后执行一些代码...
所以我这样做了:
I then wanted to execute some code after hugeFadeIn
finishes...
So I did this:
hugeFadeIn(){
//la la la
});
那是错误的,所以我这样做了:
And that was wrong, so I did this:
$(hugeFadeIn(){
//la la la
});
我仍然遇到错误.我究竟做错了什么?谢谢大家:)
And I'm still getting errors. What am I doing wrong? Thanks everyone :)
修改
根据要求,hugeFadeIn
函数的正文:
Edit
As requested, the body of the hugeFadeIn
function:
function hugeFadeIn() {
$("#huge-loader").fadeIn("fast");
}
推荐答案
如果要在hugeFadeIn
完成后运行某些内容,则需要传递回调.
If you want to run something after hugeFadeIn
finishes, you need to pass your callback in.
function hugeFadeIn(after) {
// whatever
after();
}
(如果hugeFadeIn
本身进行淡入并且不依赖于调用本身需要回调的内容.)
(If hugeFadeIn
does the fade itself and doesn't rely on calling something that itself takes a callback.)
在OP编辑后进行编辑.
function hugeFadeIn(after) {
$("#huge-loader").fadeIn("fast", after);
}
这篇关于回调中的回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!