Loading SignalR with partial view
===

I've recently followed this link http://www.kevgriffin.com/why-should-asp-net-developers-consider-signalr-for-all-projects/ to get up and started with SignalR on ASP.NET MVC3.

What I want to do is to provide a partial view with SignalR capability. Hence, when I use AJAX to load the partial view, I call the following function on success:

    function loadSuccess() {
        var chat = $.connection.chatHub;
        chat.writeMessage = function (msg) {
            $("#messages").append("<li>" + msg + "</li>");
        }

        $("#buttonSubmit").click(function () {
            chat.broadcastMessage($("#txtInput").val());
        });

        $.connection.hub.start();
    }

The troublesome thing is that it does not seem to run (inserting an `alert('hi')` just after `var chat = ...` does not cause a dialog to show up after loading the partial view). However, if I run this piece of JavaScript once the entire DOM of the containing view is loaded (i.e., the partial view has not been loaded), the script runs perfectly fine.

Does anybody have any idea why I'm bumping into this problem?