Closed ghost closed 8 years ago
Okay, i got it. maybe it will be helpful to someone. if you want to handle submit on enter key, the easiest way to make something like this:
<%= form_for Message.new do |f| %>
<p class="emoji-picker-container">
<%= f.text_field :content, class: 'form-control', data: { emojiable: true } %>
</p>
<% end %>
<script type="text/javascript">
$(document).ready(function() {
$('div[contenteditable]').keydown(function(e) {
if (e.keyCode === 13) {
// your stuff
return false;
}
});
});
</script>
Hi, ID25! Great job and great tool that worked really out from the box. I have one little question: with data attributes like in example <%= f.text_field :content, class: 'form-control', data: { emojiable: true } %> i can't send a message by pressing enter key like we usually do it with form_for, only by pressing submit button. Is it how it works?