social-share-button icon indicating copy to clipboard operation
social-share-button copied to clipboard

Uncaught ReferenceError: SocialShareButton is not defined at HTMLAnchorElement.onclick

Open gareth326771 opened this issue 5 years ago • 15 comments

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!

gareth326771 avatar Mar 07 '19 14:03 gareth326771

Add this to your application.js

//= require social-share-button

hopewise avatar Apr 06 '19 17:04 hopewise

what if i am using webpack

Mgitim avatar Aug 23 '19 19:08 Mgitim

i am using webpack too. what should i do?

x1wins avatar Sep 02 '19 06:09 x1wins

Having same problem. Anyone know?

basharabdullah avatar Mar 25 '20 15:03 basharabdullah

Also using Webpack on Rails 6. any solutions yet?

ja-meel avatar May 07 '20 02:05 ja-meel

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

gareth326771 avatar May 07 '20 08:05 gareth326771

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

muhammad-tayyab-ashraf avatar May 12 '20 05:05 muhammad-tayyab-ashraf

I have the same issue, using webpack as well.

Kinas avatar Oct 13 '20 11:10 Kinas

I too have the same issue using webpacker

DyllanCullingworth avatar Mar 03 '21 08:03 DyllanCullingworth

Same :(

atayl16 avatar Mar 25 '21 22:03 atayl16

@DyllanCullingworth you saved my life!!!

maariavld avatar Jun 03 '21 19:06 maariavld

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

pabrep avatar Nov 27 '21 18:11 pabrep

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

gabrielgomeso avatar Jan 25 '22 23:01 gabrielgomeso

@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>">

maariavld avatar Jan 28 '22 17:01 maariavld

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.

mehdi-farsi avatar Jan 22 '23 20:01 mehdi-farsi