Access JavaScript from WebSharper

I feel a little overwhelmed by the way I still need to find how to access the JavaScripts this from WebSharper client code.

I tried something like this:

 [<Inline "$this">] let this() = X<obj> 

But this splashes out $this in the generated js code, which doesn't seem to reference the correct scope object.

It seems to me that I do not need to write extra code and that it should be part of the API.

thanks

+4
source share
1 answer

Thus, the general idea is that when using WebSharper you rarely have to navigate the DOM, as with a regular site.

The presence of a large number of combinators for creating client-side markup in combination with the simplicity of RPC calls favors the javascript template for creating all the content on the client.

those. as a rule, you return data and, in turn, generate markup in the interactive mode, only resorting to markup on the server side, since this is necessary for creating bookmark locations and useful links.

Therefore, you can generally refer to DOM elements when creating them, simply by binding them to a variable for later use.

In my personal use, I wanted to access this , but later realized that this was a reference to the Kendo grid that I referenced when I created it. Therefore, I did not need to use this.

In addition, there are not so obvious technical limitations imposed by the F # -to-javascript compiler of this type. I feel uncomfortable detailing them here, as I don’t quite understand them, but feel free to see Anton in response to the fpish.net link above.

+1
source

All Articles