What is the Script# syntax for getting the following output javascript code:
$(document).ready(function() {
//..my code
});
I have tried jQuery.OnDocumentReady
but that has two problems:
(1) It can only be called from inside a function (defeats the purpose since it won't get called on startup) (2) It generates the following code, which is not quite right: Edit: My mistake, these are equivalent
$(function() {
//..my code
});
Found the answer here :
In script#, static constructors get generated as code that runs immediately as the script is loaded and parsed
So the code ended up looking like this:
[GlobalMethods]
static class Main
{
static Main()
{
jQuery.OnDocumentReady(new Action(delegate()
{
//..my code
}));
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.