ID25 / rails_emoji_picker

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

emojis not working #8

Closed yujhuang closed 8 years ago

yujhuang commented 8 years ago

<%= form_for([@conversation, @message], :remote => true, :html => { id: "conversation_form_#{@conversation.id}"}) do |f| %> <p class="emoji-picker-container" > <%= f.text_area :body, class: "form-control", "data-cid" => @conversation.id, data: { emojiable: true }%> </p> <%= f.hidden_field(:sender, :value => current_user.name) %> <% end %>

so I followed the instructions to install the gem and this is where I intended to use it.

I also set up initializers/emoji_picker.rb but I am not sure how to do the asset_path setting.

Anyway, it does not work. no sign of emojis

ID25 commented 8 years ago

I tried your form, and everything is work. You should have a copy of all emoji in your assets/images path. And don't forget to include css and js files.

  1. Check console log in your browser dev tools, any js errors or missing files?
  2. Do you use content_with_emoji helper?
yujhuang commented 8 years ago

Thanks for replying!

So I did include css and js in application.css.scss and application.js

And when I ran rails g rails_emoji_picker:install, the emoji and emoji_picker folder are automatically copied to assets/images folder

For initializer/emoji_picker.rd, I put Emoji.asset_host = 'https://natasha-yujhuang.c9.io/' and Emoji.asset_path = '/assets/images/emoji/' in it where 'https://natasha-yujhuang.c9.io/' is my local host.

However, I did not use content_with_emoji helper at all! Is this helper essential to make it work?

ID25 commented 8 years ago

@yujhuang Seems like js file for emoji does not load correctly and data attribute not treated.

  1. Make sure that you include rails_emoji_picker after all others js in application.js, and all js loads after DOM ready.
  2. Play locally with assets precompile, is it helps?
  3. If solutions above doesn't work, try to include js file below your closing </body> tag in application.html.erb like this:

config/initializers/assets.rb

Rails.application.config.assets.precompile += %w( rails_emoji_picker.js )

application.html.erb

<body>
<div class="container">
  <%= render 'layouts/header' %>
  <%= yield %>
</div>

<%= javascript_include_tag 'rails_emoji_picker' %>
</body>

Advice about Emoji.asset_path

You don't need to specify images path there. Emoji.asset_path should looks like this

Emoji.asset_path = '/assets/emoji/'
yujhuang commented 8 years ago

Alright I did as you said. I included rails_emoji_picker after all others js in application.js Then I precompile the assets. I added assets.rb stuff and added javascript_tag as you told me Also the asset_path

However, it does not work. Not showing the Emoji picker for that input

ID25 commented 8 years ago

@yujhuang Can you show me a source of your app? There are something ambiguous.

yujhuang commented 8 years ago

@ID25 Okay. I actually just set up a private repo for it. And I added you as a collaborator. https://github.com/yujhuang/MyChat Notice: this is a side project only for testing right now since I am using this for another project, though I changed some code to level it up based on its original version from other coder.

ID25 commented 8 years ago

@yujhuang I looked at what went wrong, your input has a lots of events, pub sub logic etc, i think there is a conflict, which i can't figure out right now. You've installed emoji picker correctly, if you create form, it will work, you can try to find the reason in your chat.js and user.js to achieve compatibility, i don't have time to do that now.

yujhuang commented 8 years ago

Alright, if that is the case. I will close this case. But you are always welcome to look at it if you got chances. I will try to figure it out though.