Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Requirejs implementation

$
0
0
Hi,

Thanks for creating this excellent library. I am attempting to get the requirejs implemententation to work.

My code is as follows.
engine.Script.moduleLoader = new ModuleLoader(engine);
string currentDir = FileOperations.GetCurrentlyExecutingAssemblyLocation();
engine.Execute(File.ReadAllText(currentDir + @"\Scripts\require.js"));
engine.Execute(@"require.load = function (context, name, url) {
moduleLoader.LoadModuleAsync(context, name, url);
}");
The following exception is thrown when I execute "engine.Script.moduleLoader = new ModuleLoader(engine);"

First Chance Exception: RuntimeBinderException
Message: 'System.Dynamic.DynamicObject' does not contain a definition for 'moduleLoader'

The requirejs file is loaded and the objects it creates are visible in the engine.Script

Do you have any ideas why this exception is thrown? I am not 100% clear what the context variable is, how is context accessed or created. What does context mean?

I did find the following articles but I can't work out if they have relevance to the problem I am facing.

Adding properties or Dynamic objects in ClearScript
https://clearscript.codeplex.com/discussions/433131

https://stackoverflow.com/questions/2630370/c-sharp-dynamic-cannot-access-properties-from-anonymous-types-declared-in-anot

http://www.solutionevangelist.com/post/14

Due to the fact that V8 does not implement a DOM, loading libraries like jQuery can prove difficult since there are no window or document objects in the engine. I noticed the test projects have a class called MockDOM but this is a very barebones implementation. For something more fully featured I've been looking at using jsdom http://lab.arc90.com/2010/11/22/jsdom/ . jsdom seems to be developed specifically for node but I am hoping it will work in ClearScript also. Do you know of any techniques that will enable me to load jQuery or other libraries that require the DOM to load and execute in ClearScript?

Any help or suggestions you have in realation to these matters is appreciated.

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images