Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: jQuery is not defined #240

Open
nateguy opened this issue Apr 14, 2020 · 0 comments
Open

ReferenceError: jQuery is not defined #240

nateguy opened this issue Apr 14, 2020 · 0 comments

Comments

@nateguy
Copy link

nateguy commented Apr 14, 2020

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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant