ReferenceError: jQuery is not defined
nateguy opened this issue · comments
Nathan Tseng commented
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}