Matija Grcic
Matija Grcic

Reputation: 13371

SignalR Undefined is not a function

I have the following in my layout

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>

Scripts in my scripts folder

and in the Global.asax Application_Start()

BundleTable.Bundles.EnableDefaultBundles();

SignalR works fine but it's throwing an error

Uncaught TypeError: undefined is not a function

So it doesn't work well with bundles or is there something else?

Upvotes: 1

Views: 1173

Answers (2)

Alexey Lyubko
Alexey Lyubko

Reputation: 11

Just add ; in signalr-x.x.x.js after ...{ n.signalR.version = "1.1.2" }(window.jQuery).

The result string is:

...{ n.signalR.version = "1.1.2" }(window.jQuery);

Upvotes: 1

Matija Grcic
Matija Grcic

Reputation: 13371

Obviously the

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script

is not working and after some experiments i've solved it by moving signalr scripts to different folder (Scripts/signalr) and used the following in my _Layout.cshtml file.:

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>
<script src="@Url.Content("~/Scripts/signalr/jquery.signalR-0.5.3.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>

Upvotes: 3

Related Questions