diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-11-11 20:41:28 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-11-11 20:41:28 (GMT) |
commit | 5e93f1c5d1f6d008a80e0dcdca3a4ff86ebeec58 (patch) | |
tree | e0396797ac497604a1f117e48beae72c8e0f6c49 /apps/samples/miles | |
parent | cf43fb60b0800d9f5bf5b7220a86afbb63aaad89 (diff) | |
download | uscxml-5e93f1c5d1f6d008a80e0dcdca3a4ff86ebeec58.zip uscxml-5e93f1c5d1f6d008a80e0dcdca3a4ff86ebeec58.tar.gz uscxml-5e93f1c5d1f6d008a80e0dcdca3a4ff86ebeec58.tar.bz2 |
Send chat text on return and clear text field
Diffstat (limited to 'apps/samples/miles')
-rw-r--r-- | apps/samples/miles/miles.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/samples/miles/miles.js b/apps/samples/miles/miles.js index 8dce94c..8afbf21 100644 --- a/apps/samples/miles/miles.js +++ b/apps/samples/miles/miles.js @@ -301,28 +301,38 @@ function Miles(element, params) { self.chatSendButton = new Button({ label: "Send", onClick: function(){ - //alert(self.chatInput.value); self.xhr.post({ // The URL to request url: "http://" + self.scxmlURL + "/miles/text", contentType: 'application/json', postData: dojo.toJson({ - message: self.chatInput.value, + message: self.chatInput.get('value'), userid: self.email }), error: function(err) { console.log(err); }, - load: function(result) {} + load: function(result) { + self.chatInput.set('value', ''); + } }); } + }, dojo.query("div.chatSendButton", element)[0]); // the chat interface self.chatInput = new TextBox({ name: "chatInput", style: "width: 100%", + onKeyDown: function(e) { + var code = e.keyCode || e.which; + if( code === 13 ) { + e.preventDefault(); + self.chatSendButton.onClick(); + return false; + } + }, }, self.chatInputElem); |