-
Notifications
You must be signed in to change notification settings - Fork 43
Client Side Events
Rocky Bevins edited this page Jun 13, 2019
·
4 revisions
You can write client side event handlers by setting the 'evt' (event) property on any outgoing message object and adding a handler to your client script.
Somewhere server-side we send a client a message with a defined evt property. In this case 'showAlert'.
World.msgPlayer(s, {
msg: '',
evt: 'showAlert',
data: {alert: 'Hello World'}
});
Client side handler:
document.addEventListener('showAlert', function(e) {
e.preventDefault();
alert(e.command.data.alert);
}, false);