Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Nuxt : how can i call a method if the document is ready (all css already loaded)

I need to call the function after the document is ready, because i need access to the css class dot.

mounted () {
    $(this).ready(function () {
      this.methods.addSlick()
    })
},
methods: {
    addSlick () {
      $(this.$refs.yourClass).slick({
        slidesToShow: 1,
        slidesToScroll: 1,
        mobileFirst: true,
        ininite: false,
        dots: true,
        customPaging (slider, i) {
          return '<span class="dot">s</span>'
        }
      })
    }
}

Error in the Console:

    jquery.js?1157:3827 Uncaught TypeError: Cannot read properties of undefined (reading 'addSlick')
        at HTMLDocument.eval (ProductSlider.vue?5b8f:30:1)
        at mightThrow (jquery.js?1157:3534:1)
        at process (jquery.js?1157:3602:1)
    eval @ ProductSlider.vue?5b8f:30
    mightThrow @ jquery.js?1157:3534
    process @ jquery.js?1157:3602
    setTimeout (async)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

the error message tells you that you are trying to access addSlick of undefined, that means this.methods in your first code block is undefined. This happens, because you're wrapping it in a jQuery ready call which changes the this context which is not what you want here. The ready call is not necessary, because if you execute something in mounted you can be sure that your ref yourClass is available in the dom.

If you remove lines 2 and 4 from your first code block the error message should be fixed.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!