huacnlee / social-share-button

Helper for add social share feature in your Rails app. Twitter, Facebook, Weibo, Douban ...
MIT License
582 stars 311 forks source link

Uncaught ReferenceError: SocialShareButton is not defined at HTMLAnchorElement.onclick #183

Open gareth326771 opened 5 years ago

gareth326771 commented 5 years ago

Hello,

I have installed the gem ok and get the social share buttons to show, but when I click (in dev environment) nothing happens…

I get the following error in the console -

Uncaught ReferenceError: SocialShareButton is not defined at HTMLAnchorElement.onclick (VM7889 62:777) onclick @ VM7889 62:777

Any help appreciated!

hopewise commented 5 years ago

Add this to your application.js

//= require social-share-button
Mgitim commented 5 years ago

what if i am using webpack

x1wins commented 5 years ago

i am using webpack too. what should i do?

basharabdullah commented 4 years ago

Having same problem. Anyone know?

ja-meel commented 4 years ago

Also using Webpack on Rails 6. any solutions yet?

gareth326771 commented 4 years ago

Thanks @hopewise but should have specified I am also using Webpack :)

muhammad-tayyab-ashraf commented 4 years ago

@gareth326771 Any solution for this issue if we are using webpack?

Kinas commented 4 years ago

I have the same issue, using webpack as well.

DyllanCullingworth commented 3 years ago

I too have the same issue using webpacker

atayl16 commented 3 years ago

Same :(

maariavld commented 3 years ago

@DyllanCullingworth you saved my life!!!

pabrep commented 2 years ago

Any official solution to use it with rails 6? @DyllanCullingworth website is down.

gabrielgomeso commented 2 years ago

Still no solution @maariavld, could you explain what you did to make it work?

maariavld commented 2 years ago

@gabrielgomeso I ended up not using it in the end and I forgot how I made it work, but it was with an article written by @DyllanCullingworth. I ended up using this, as my use case was quite simple, to share online a "premade" post:

   <a href="https://twitter.com/intent/tweet?url=<your_link>&text=<your_text>"  onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=240,width=600');return false;" class= "your_css_class">

   <a href="https://www.facebook.com/sharer/sharer.php?u=<your_link>" onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=240,width=600');return false;" class="<your_css_class>">
mehdi-farsi commented 1 year ago

A workaround is to copy then content of this file in a javascript/vendor/social-share-button.js file and then import this file in javascript/application.js.