2

Why this doesn't work in Firebug console:

function(s,e) {
setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
}

While this does:

setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)

2 Answers 2

6

It doesn't work because you don't call the other anonymous function wrapping your setTimeout, how is it actually called?

You have to either name it and call it:

function someFunc(s,e) {
    setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
}
someFunc();

Or wrap it in parens and call it immediately

(function(s,e) {
    setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
})();

Or name it and call it on document load:

JS:

function someFunc(s,e) {
    setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
}

HTML

<body onload='someFunc'>
....
Sign up to request clarification or add additional context in comments.

Comments

2

Because you're not calling the function in the first example. You need to call the function, which you can do as follows. The parentheses around the function are there to prevent a syntax error: a function expression (which is what your example is) on its own is not a valid statement. The parentheses at the end call the function.

(function(s,e) {
  setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
})();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.