ID25 / rails_emoji_picker

Add emoji to your app :smiley_cat:
143 stars 41 forks source link

AJAX loaded forms #16

Open sreeraj-nyros opened 8 years ago

sreeraj-nyros commented 8 years ago

@ID25 ,

I was working with ajax forms. emoji picker is not available when the form is loaded on ajax call but working fine when form is loaded with the page.

Could you help me on this?

RonanLOUARN commented 7 years ago

Up!

RonanLOUARN commented 7 years ago

I found the solution.

Just put this gem helper methods in messages controller. http://textup.fr/184548YN

Has you can see i use method 'content_with_emoji(message.content)' in create method. And under private, all method are in gem helper... Just copy past all method under private except first ('message_params'), it's my params method.

if you want only gem helper: http://textup.fr/184541W8 But you have to patch line 68 (url = image_tag("emoji/#{img[:name]}.png")[/img.?src="(.?)"/i, 1]) to (url = ActionController::Base.helpers.image_tag("emoji/#{img[:name]}.png")[/img.?src="(.?)"/i, 1])) Sorry for my english.

Ins4f commented 7 years ago

run this script on page loaded with ajax.

$(function () { window.emojiPicker = new EmojiPicker({ emojiable_selector: '[data-emojiable=true]', assetsPath: '/assets/emoji_picker', popupButtonClasses: 'fa fa-smile-o', }); window.emojiPicker.discover(); });