That's strange. It's working perfectly for me. Which version of WebSharper are you using on which OS and how do you compile your project? Are you sure the WebSharper compiler is run on the project? Can you find JS file it generates from your source?

By on 8/10/2015 1:06 AM ()

Yeah, I'm sure the WebSharper compiler is being run. I can see its output in my xbuild output.

paket.lock has:

1
2
WebSharper (3.4.8.187)
WebSharper.UI.Next (3.4.8.156)

My project source can be found here: https://github.com/spiffytech/webmusic

The sample WebSharper code is in src/WebMusic/WebSharper.fs.

Here's the contents of the WebMusic.js file that gets generated:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function()
{
 var Global=this,Runtime=this.IntelliFactory.Runtime,alert,UI,Next,Var,Client,Doc,List,T;
 Runtime.Define(Global,{
  WebMusic:{
   Web:{
    Client:{
     Alert:function()
     {
      return alert("Clicked!");
     },
     Widget:function()
     {
      var rvInput,arg20;
      rvInput=Var.Create("");
      arg20=List.ofArray([Doc.TextNode("You typed: "),Doc.TextView(rvInput.get_View())]);
      return Doc.Concat(List.ofArray([Doc.Input(Runtime.New(T,{
       $:0
      }),rvInput),Doc.Element("p",[],arg20)]));
     }
    }
   }
  }
 });
 Runtime.OnInit(function()
 {
  alert=Runtime.Safe(Global.alert);
  UI=Runtime.Safe(Global.WebSharper.UI);
  Next=Runtime.Safe(UI.Next);
  Var=Runtime.Safe(Next.Var);
  Client=Runtime.Safe(Next.Client);
  Doc=Runtime.Safe(Client.Doc);
  List=Runtime.Safe(Global.WebSharper.List);
  return T=Runtime.Safe(List.T);
 });
 Runtime.OnLoad(function()
 {
  return;
 });
}());
By on 8/11/2015 1:42 PM ()

Just tried your generated code and it should work correctly so as Adam noted there's probably something wrong with loading the resources? Seeing the source of the loaded page on which you get the error would indeed be very helpful.

By on 8/12/2015 9:12 AM ()

I took your WebSharper.fs file, stuck it into a UI.Next Client-Server Application template, and it happily works, so as we expected the code is OK as is.

Can you paste in the view-source of your app when you try to run it? For a reference, mine is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html>
	<head>
		<meta id='websharper-data' name='websharper-data' content='{"$TYPES":[["WebSharper","Web","InlineControl"]],"$DATA":{"$V":{"ws592800087":{"$T":0,"$V":{"args":[],"funcName":["WebMusic","Web","Client","Widget"]}}}}}' />
		<script src="/Scripts/WebSharper/WebSharper.Core.JavaScript/Runtime.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.Web.js" type="text/javascript" charset="UTF-8">

		</script><script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript" charset="UTF-8">

		</script><!--[if lte IE 7.0]>
		<script src="/Scripts/WebSharper/WebSharper.Main/Json.js" type="text/javascript" charset="UTF-8">

		</script><![endif]-->
		<script src="/Scripts/WebSharper/WebSharper.Main.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/Application3.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.Collections.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.UI.Next.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.Html.Client.js" type="text/javascript" charset="UTF-8">

		</script><script type='text/javascript'>
		if (typeof IntelliFactory !=='undefined')
		  IntelliFactory.Runtime.Start();
		</script>

	</head><body>
		<div><h1>Enter text below</h1><div id="ws592800087"></div><button onclick="WebMusic.Web.Client.Alert(this, event)">Click me!</button></div>
	</body>
</html>```
By on 8/11/2015 3:33 PM ()

Apologies for the delay, I had some technical issues when my system upgraded to F# 4.0, and I only just got a 3.1 environment working again.

Here's my page source. The big difference I see is mine is missing a reference to WebSharper.Web.js. Why might that be?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>
	<head>
		<meta id='websharper-data' name='websharper-data' content='{"$TYPES":[],"$DATA":{"$V":{"ws851845891":{"$V":{"args":[],"funcName":["WebMusic","Web","Client","Widget"]}}}}}' />
		<script src="/Scripts/WebSharper/WebSharper.Core.JavaScript/Runtime.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebMusic.js" type="text/javascript" charset="UTF-8">

		</script><script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript" charset="UTF-8">

		</script><!--[if lte IE 7.0]>
		<script src="/Scripts/WebSharper/WebSharper.Main/Json.js" type="text/javascript" charset="UTF-8">

		</script><![endif]-->
		<script src="/Scripts/WebSharper/WebSharper.Main.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.Collections.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.UI.Next.js" type="text/javascript" charset="UTF-8">

		</script><script src="/Scripts/WebSharper/WebSharper.Html.Client.js" type="text/javascript" charset="UTF-8">

		</script><script type='text/javascript'>
		if (typeof IntelliFactory !=='undefined')
		  IntelliFactory.Runtime.Start();
		</script>

	</head><body>
		<div><h1>Enter text below</h1><div id="ws851845891"></div><button onclick="WebMusic.Web.Client.Alert(this, event)">Click me!</button></div>
	</body>
</html>
By on 8/15/2015 6:14 PM ()

Ah! I've figured out the problem. The current F# Project Scaffold puts all assemblies into bin/project/, and ASP.NET doesn't serve out of there. I was copying bin/project/project.dll to bin/project.dll, which was enough for ASP.NET to find and serve the site, but apparently messed up WebSharper's asset loading. Copying bin/project/* to bin/ fixed my JavaScript error.

I've been messing with ASP.NET's assembly probing, but haven't gotten it to load my website from bin/project/.

By on 8/20/2015 7:18 PM ()

Cool, glad you figured it out. You actually bring up a valid point probing assemblies in subfolders inside bin, this might just make a good enhancement ticket.

By on 8/21/2015 3:40 AM ()

Sounds like you are trying to append to a DOM node that doesn't exist.

By on 8/9/2015 3:35 PM ()

The DOM node I'm injecting the client code into should certainly exist. My project is just a copy/paste of the example from the blog, which just inserts the client widget into a hardcode Content.Doc(div[client <@ Client.Widget() @>]). Another project I tried this in, which just injected the client portion into Content.Doc, shows the same error.

By on 8/9/2015 8:19 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper