无法点击网页上的按钮

时间:2014-03-30 17:58:06

标签: javascript jquery html5

点击网页底部时,是否有任何理由不显示提示?其他按钮可以很好地在我的网页上工作,但是"创建空间"按钮不起作用,我不知道为什么。

任何想法?

    ViewBag.Title = "Chat";
}
<h2>General Chat</h2>

<div id="wrapper">

    <div id="upper-wrapper">
        <div id="available-rooms-dialog">
            <h4>Available Rooms</h4>
            <input type="button" onclick="s = prompt('Enter a new Room Name', 'Name');" id=" createroom" value="Create Room" />
        </div>
        <div id="discussion-dialog">
            <textarea rows="30" cols="50" id="discussion"></textarea>
        </div>
    </div>
    <div id="message-dialog">
        <textarea rows="3" id="message">Type your message</textarea>
        <br/>
        <input type="button" id="sendmessage" value="Post" />
        <input type="hidden" id="displayname" />
        <input type="checkbox" id="enter-sends-message"/>
        Enter sends message
    </div>
</div>

@section scripts {
    <!--Script references. -->
    <!--The jQuery library is required and is referenced by default in _Layout.cshtml. -->
    <!--Reference the SignalR library. -->
    <script src="~/Scripts/jquery.signalR-2.0.2.min.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src="~/signalr/hubs"></script>
    <!--SignalR script to update the chat page and send messages.-->
    <script type="text/javascript">
        var json;


    $(function () {



        // Reference the auto-generated proxy for the hub.
        var chat = $.connection.chatHub;
        // Create a function that the hub can call back to display messages.
        chat.client.addNewMessageToPage = function (name, message) {
            // Add the message to the page.

            //TODO: Add Record to Server
            $.ajax(
            {
                type: "Post",
                url: "@Url.Action("AddMessage", "Home")",
                data: { messageCont: message.toString() },
                success: function (data) {
                    for (var i = 0; i < data.length; i++) {
                        //access with data[i].modelattribute
                    }
                }
            });

            $.ajax(
            {
                type: "Get",
                url: "@Url.Action("GetMessages", "Home")",
                success: function (data) {
                    json = data;
                    var obj = JSON.parse(json);
                    for (var i = 0; i < data.length; i++) {
                        //access with data[i].modelattribute
                        $('#discussion').append(htmlEncode(obj[i].Author) + " : " + htmlEncode(obj[i].Message) + "\r\n");
                    }
                }
            });

        };
        // Get the user name and store it to prepend to messages.
        $('#displayname').val(prompt('Enter your name:', ''));
        // Set initial focus to message input box.
        $('#message').focus();
        // Start the connection.
        $.connection.hub.start().done(function () {
            $('#sendmessage').click(function () {
                // Call the Send method on the hub.
                chat.server.send($('#displayname').val(), $('#message').val());
                // Clear text box and reset focus for next comment.
                $('#message').val('').focus();
            });
        });
    });

    // This optional function html-encodes messages for display in the page.
    function htmlEncode(value) {
        var encodedValue = $('<div />').text(value).html();
        return encodedValue;

    }

</script>

}

0 个答案:

没有答案