tabalinas / jssocials

Social Network Sharing jQuery Plugin
http://js-socials.com
MIT License
464 stars 104 forks source link

ReferenceError: jQuery is not defined #240

Open nateguy opened 4 years ago

nateguy commented 4 years ago

I have installed jssocials using yarn and I'm using typesript. I have already initialized jquery in my code. However it persistently says jquery is not defined. Have even tried to defer loading the script.

import $ from "jquery"
import "jssocials/dist/jssocials.js"

const INIT_DONE_CLASS = "js-jssocial--init-done"

const init = (selector: string | JQuery = ".js-jssocial") => {
  $(selector).each((idx, el) => {
    const $el = jQuery(el)
    if ($el.hasClass(INIT_DONE_CLASS)) { return }

    ($el as any).jsSocials({
      shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp"]
    })
    $el.addClass(INIT_DONE_CLASS)
  })
}

export default {init}