emojionearea: Can not submit form with event keypress
I cant submit a form when pressing enter in textarea. It only works when I click to somewhere, then click to the textarea and press enter. My form
<form id="add-msg-form">
<div class="panel-footer">
<div class="input-group" style="display: -webkit-box" id="txtbox">
<textarea id="txtMessage" placeholder="Vui lòng nhập nội dung tin nhắn" ></textarea>
<span class="input-group-btn">
<button class="btn btn-info" id="btnSend" type="submit">Send</button>
</span>
</div>
</div>
</form>
$(document).ready(function() {
$("#txtMessage").emojioneArea({
events: {
keypress: function (editor, event) {
if(event.which == 13){
console.log('event:keypress'); //work
$('#add-msg-form').submit(); //not work
$('#txtMessage').val(''); //not work
}
},
}
});
});
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (10 by maintainers)
use
event.preventDefault()
for that, example https://jsfiddle.net/1v03Lqnu/131/use emojione for convert unicode emojis to images, first of all, install emojione, prefer installation via composer
composer require emojione/emojione
next, in your php for rendering html from db
seems submit works well https://jsfiddle.net/1v03Lqnu/114/
@mervick @lasdeparq Working perfectly in my code. Thank you very much, I hope that when you learn more you can reciprocate in some way.
@Fabiombrs https://jsfiddle.net/1v03Lqnu/2675/