I have one function for send message if the Enter is pressed. But, I created one button for send message too, and if I call this function, the message does not send, and I added the click event.
function inputKeyDown(event, inputBox) {
// Submit on enter key, dis-allowing blank messages
if (event.keyCode === 13 && inputBox.value || event.onclick && inputBox.value) {
// Send the user message
Api.sendRequest(inputBox.value, context);
// Clear input box for further messages
inputBox.value = '';
Common.fireEvent(inputBox, 'input');
}
}
I try add one click event inside this if condition and does not work, I test the button with one alert event and works fine when I click.
Check my html:
<label for="textInput" class="inputOutline">
<input id="textInput" class="input responsive-column"
placeholder="Type something" type="text"
onkeydown="ConversationPanel.inputKeyDown(event, this)">
<button class="Testbutton" onclick="ConversationPanel.inputKeyDown(event, this)">
<i class="icon send"></i>
</button>
</label>
My function onkeydown works fine to send the message. But when I changed the function added one onclick event, my button doesn't work. I debugged the button with alert and work perfectly.
What am I doing wrong? Someone can help me please.
Common?onclick=?<button class="Testbutton" onclick="alert('test')">I try use the same function but does not work =\ConversationPanel.inputKeyDown(event, this)then of course it won't work, because you need to pass input (2nd param)