Hi,

I have a function which renders templates for my single page application. The function gets its data via socket.io.
Code:
function renderTemplate() {
    
    var result;

    io.emit('tpldata request', {'templates':['sidebar'],'token': token },
        // callback function
	function( response ) {
		result = response;
	}

    );

    return result;
}

// Returns undefined
$('#sidebar').html( renderTemplate() );
However, the problem with this function is that it will return 'result' when it is still undefined, since the callback function of socket io isn't executed yet ...

In jQuery (ajax) you can set the property 'async' to false, but does anybody know how to do this with socket.io?

Thanks in advance!

Christophe