3

Is there a way to specify the jQuery alias Script# uses when generating JavaScript? For example, if we expect our version of jQuery as “$myJQuery” using noConflict(true), is there a way to get Script# to compile all references to "$myJQuery" instead of "jQuery" when loading the generated script?

2 Answers 2

1

I believe you will need to recompile the jQuery import library.

You can do so by downloading the source code at https://github.com/nikhilk/scriptsharp, then modifying jQuery.cs so that [ScriptName("$")] becomes [ScriptName("$myJQuery")].

Once recompiled, drop the jQuery dll into your Script# project folder and re-add the jQuery reference using your new dll instead of the stock dll.

Sign up to request clarification or add additional context in comments.

1 Comment

It also seems like a good workaround is to put a script literal in a static constructor, such as: static public class Startup { static Startup() { Script.Literal("$ = $myJQuery;"); } }
0

If you don't want to branch the Script# source, a good workaround is to just manually set the local alias to your overridden one in a static constructor:

static public class Startup
{
    static Startup()
    { 
        Script.Literal("$ = $myJQuery;"); 
    }
}

If you're using jQuery in any static constructors, be aware of the order of their generation in the final script.

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.