Jump to the post that solved this thread.
Solved: 5 Years, 1 Week ago Emoji replacing text
#1
Solved: 5 Years, 1 Week ago
Hi,
I have this piece of code which insers a specified emoji into a input field (text).

jQuery("img.smilie").click(function () {
 var emoji_value = jQuery(this).attr('data-emojiname');
$('#insert_emoji').val(''+emoji_value+'');
});

However, when you're typing something like: "Hello!" and then you click on a emoji, it replaces the whole text with just the emoji + it won't work with multiple emojis.

Here's a video:

https://u.pomf.is/lbyame.mp4

Thank you for reading.  Smile
Reply
#2
Solved: 5 Years, 1 Week ago
That's because you're setting the value to just the emoji value.

Try:
jQuery("img.smilie").click(function () {
  var current_input_value = jQuery("#idOfInput").val();
  var emoji_value = jQuery(this).attr('data-emojiname');
  $('#insert_emoji').val(current_input_value + emoji_value);
});

Obviously change the "#idOfInput" to the actual ID of your input box.
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)