Reputation: 103
On the vuejs.org website there is this function.
I want to replicate this to test some code i am writing in an on click function on a table row using jquery.
$("#table1 tr").click(function () {
// alert($(this).text());
// alert($(this).children("td").html());
// app.greet();
});
I want to call the vue function there but my vue code is written in the script and i am using export default like so.
export default {
data() {
return {
}
etc.
}
If i want to use this vue function in jquery how do i call it.
Upvotes: 3
Views: 11450
Reputation: 31
export default {
mounted(){
$("#table1 tr").on('click',()=> {
this.greet()
});
},
methods:{
greet(){
console.log('greet method')
}
}
}
Upvotes: 0
Reputation: 3434
You have to instantiate the App, then you can call the method on it:
import Vue from 'vue'
import App from './app.vue'
const app = new Vue(App)
$("#table1 tr").click(function () {
app.greet()
})
Upvotes: 8