Static GitHub Issues

[1708] Event Handling Issue with External JS

prev: Unit Tests Setup
next: Can not access env variables from plugin

If suppose I handle some click events for nuxt pages(spa) in external js and include in head tag, click events happen only when page refresh

For example, index.js included in head tag

$(document).ready(function () {
 $('.sample').on('click', function () {
   alert('sample')
})
}

pages index.vue

<template>
 <div class='sample'>
    data
</div>
<template>

how to use external js events in nuxt pages without DOM issue?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1530">#c1530</a>)</em></sub></div>