I’m on my way to my second spike for one of my clients on playing with ScriptSharp to extend Rasta with Ajax functionality, and really wanted to be able to select elements as I would in CSS, using selectors (something I got quite used to with jQuery).
So how do you call random code in ScriptSharp without resorting to evil eval code? You create a function of course! Here’s the snippet.
public static DOMElement GetElementsBySelector(string selector, DOMElement root)
return new Function("return document.getElementsBySelector(selector, arg);", "selector", "arg")
.Call(Document.DocumentElement, selector, root) as DOMElement;
In one word, sweet.