I am new to Vue and I am trying to display a table, but for every row, i want to call a js function pasing a value from the item dysplay on the row.
<div id="app">
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Breed</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<tr v-for="cat in cats">
<!-- I changed the default delimiter of Vue '{{' for '((' because I have
golang as a server-side language and interfers with the '{{' notations
of golang templates -->
<td>*((cat.name))</td>
<td>*((cat.age))</td>
<td>*((cat.breed))</td>
<td>*((cat.gender))
<script type="application/javascript">
// This is the script I can not make work
*(( callCustomFunction(cat.id, cat.age) ))
</script>
</td>
</tr>
</tbody>
</table>
</div>
And the js part of my code is:
<script type="text/javascript">
const app = new Vue({
el:'#app',
data:{
sales: JSON.parse({{.JSON}}),
},
delimiters: ['*((', '))'],
methods: {
/* This is the function that calls to my
custom fuction in an import customFunction.js */
callCustomFunction: function() {
customFunction(id, age);
},
});
</script>
But I have this reasult as a javascript error in the browser:
Uncaught ReferenceError: callCustomFunction is not defined
The function I need to call it every time the row is loaded, and it needs to be called with the parameter of the item in the row display.
Thanks a lot!
customFunctiondo? What value does it return?