Nesting function call
I want the notify to occur only after the unblock event, however both occur together. I am pretty new to JQuery.
function isSuccess()
{
$(function () {
setTimeout('unblock()',1000);
$.notifyBar({
html: "Thank you, your settings were updated!",
开发者_高级运维 delay: 2000,
animationSpeed: "normal"
});
});
}
$(function () {
setTimeout(function() {
unblock();
$.notifyBar({
html: "Thank you, your settings were updated!",
delay: 2000,
animationSpeed: "normal"
});
}, 1000);
});
If you want notifyBar
to be executed after unblock
, place it after unblock
setTimeout(function() {
unblock();
$.notifyBar({
...
});
},1000);
wrap in another anonymous function
function isSuccess()
{
$(function () {
function unblockAndNotify() {
unblock();
$.notifyBar({
html: "Thank you, your settings were updated!",
delay: 2000,
animationSpeed: "normal"
});
}
setTimeout(unblockAndNotify,1000);
});
}
EDIT: I was going to do what Darin did and declare the function inline with the setTimeout, but didn't want to introduce too many new concepts at once.
You need to re-arrange the order of calls.
Either you have to call $.notifyBar()
from within unblock()
or you are doing something like
setTimeout(function(){
unblock();
$.notifyBar({
html: "Thank you, your settings were updated!",
delay: 2000,
animationSpeed: "normal"
});
}, 1000);
精彩评论