rtc-io / rtc.io-website

DOCS: Main rtc.io website and docs

Home Page:http://www.rtc.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tutorial-simple-text-share too easy to get wrong

garrows opened this issue · comments

I was following the tutorial and had some problems. Thought I would share my thoughts as I'm sure other have encountered the same.

The "contenteditable DOM element" code should really be shown. I used this:

<textarea rows="20" cols="80" id="messages"></textarea>

However this doesn't work with the event because it's innerHTML is empty so I suggest changing the bindDataEvents function to use .value like so:

function bindDataEvents(channel) {
    // Receive message
    channel.onmessage = function (evt) {
        messageWindow.value = evt.data;
    };

    // Send message
    messageWindow.onkeyup = function (evt) {
        channel.send(this.value);
    };
}

Hope this helps.

I did this to fix it:

<style>
    #messages {
            border: 1px solid black;
            min-height: 20px;
    }
</style>
<div id="messages" contenteditable></div>

Are you ok with that?

Actually, that's not with the require.js in tutorial-simple-text-share... let me give that a go, too.

Yeah that's perfect :)

Thanks for your feedback