Reputation: 5619
I am looking at this tutorial and the author assumes some piece of knowledge that I must not have.
They state this is the javascript code:
if (typeof (SDK) == "undefined")
........snipped for brevity see full code at tutorial link
};
and then they say you can call it with:
SDK.Action.ApproveRequest(salesOrderId, approvedById);
What is eluding me is don't I have to wrap the "chunk" of javascript code in some function wrapper to be able to call it....or can you just put random javascript in a js file and somehow it works?
Also my title is weak and I will update it with better keywords if you have any suggestions.
TIA
Upvotes: 0
Views: 33
Reputation: 943214
can you just put random javascript in a js file and somehow it works?
Yes. JS in a JS file is interpreted when loaded via a script element.
If the JS includes a function declaration, it is interpreted as "Here is a function!".
Other kinds of expressions are also interpreted.
If that wasn't the case then it would be impossible to call any function (other then via intrinsic event attributes).
Upvotes: 1