How do I render a new jade view upon a socket event?
<p>I have two major js files, one on the server side which is the <code>server.js</code> and another on the client side, which is <code>enterchat.js</code>. These two files are the ones which will communicate via socket.io. All socket events are working as expected.</p>

<p><strong>server.js</strong></p>

<pre><code>var express = require('express'),
...
server = require('http').createServer(app),
io = require('socket.io').listen(server);

var usernames = [],
    username_sockets = [];

...

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use('/', express.static(__dirname+'/public/'));

app.get('/chat', function (req, res) {
    res.render('checkUsername', {title:'Socket IO Chat'});
});

app.get('/chatwindow', function (req, res) {
    res.render('chatwindow', {title:'Welcome to chat window'});
});

io.sockets.on('connection', function (socket) {

    socket.on('disconnect', function () {
        ...
        delete username_sockets[socket.id];
        console.log("Disconnected from " + user);
    });

    socket.on('newusr', function (newusrname) {
        console.log("New user name request:: " + newusrname);
        if(usernames.indexOf(newusrname) &gt;= 0)
        {
            console.log("Already used username..");
            socket.emit('usernameTaken', newusrname);
        }
        else
        {
            socket.emit('usernameavlbl', newusrname);
        }
    });

    socket.on('startchat', function (usernameAvailable) {
        if(usernames.indexOf(usernameAvailable) &gt;= 0)
        {
            console.log("Just taken username..");
            socket.emit('usernameJustTaken', usernameAvailable);    //returning the username that was just taken
        }
        else
        {
            usernames.push(usernameAvailable);
            console.log("Opening chat window for "+usernameAvailable);
            username_sockets[socket.id] = usernameAvailable;

            //  trying to render jade view to open chatwindow on socket event
        }
    });

    socket.on('sndmsg', function (message) {
        socket.broadcast.emit('msgreceive', message, username_sockets[socket.id]);
    });

    socket.on('typing', function (username) {
        socket.broadcast.emit('usertyping', username);
    });

    socket.on('stoppedtyping', function (username) {
        socket.broadcast.emit('userstoppedtyping', username);
    });
});

server.listen(8080,'0.0.0.0');
console.log("Listening on 8080..");
</code></pre>

<p><strong>enterchat.js</strong>    </p>

<pre><code>var socket, usernameAvailable;

    $(document).ready(function () {
        connect();

    ...

    ...

    $('#checkBtn').on('click', function(event) {
        if($('#username').val() == '')
            alert("Choose a username");
        else
        {
            var newusrname = $('#username').val();
            socket.emit('newusr', newusrname); 
        }
    });

    ...

    socket.on('usernameTaken', function (message) {
        alert(message + " is already taken. Try another one..");
    });

    socket.on('usernameJustTaken', function (message) {
        alert(message + " was just taken. Try another one..");
    });

    socket.on('usernameavlbl', function (newusrname) {
        $('#chataway').attr('disabled', false);
        usernameAvailable = newusrname;
    });

    $('#chataway').on('click', function () {
        socket.emit('startchat', usernameAvailable);
    });
    });

    function connect () {
        socket = io.connect(null);
    }
</code></pre>

<p><em>My question: How do I render the <code>chatwindow</code> view upon the socket event <code>startchat</code>?</em></p>

<p>I looked at this question: <strong><a href="https://stackoverflow.com/questions/8644580/in-express-js-how-can-i-render-a-jade-partial-view-without-a-response-object">In Express.js, how can I render a Jade partial-view without a &quot;response&quot; object?</a></strong>, but I am not sure as to how to add it in my code so that a fresh jade view (chatwindow) is loaded on the browser.</p>