Here is my basic table within laravel blade file
Each edit button calls a vue method when clicked
<types-page inline-template>
<div>
<!-- table -->
<table id="choose-address-table" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<th>Name/Nr.</th>
<th>Street</th>
<th>Town</th>
<th>Postcode</th>
<th>Country</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nr"><span>50</span>
</td>
<td>Some Street 1</td>
<td>Glasgow</td>
<td>G0 0XX</td>
<td>United Kingdom</td>
<td>
<button type="button" @click="edit()">edit</button>
</td>
</tr>
<tr>
<td class="nr">49</td>
<td>Some Street 2</td>
<td>Glasgow</td>
<td>G0 0XX</td>
<td>United Kingdom</td>
<td>
<button type="button" @click="edit()">edit</button>
</td>
</tr>
</tbody>
</table>
</div>
</types-page>
Here is the vue component
It handles the edit() method. The method fires ok as ive tested that
Im trying to use jquery to select the data and log each row in the hard coded table
i want to be able to access log the data in each row
Its the jquery selectors that cant seem to target the table
<script>
export default {
name: "types-page",
data() {
return {
typeError: false
}
},
methods: {
edit() {
var $row = $(this).closest("tr"); // Find the row
var $text = $row.find(".nr").text(); // Find the text
console.log($text)
}
}
}
</script>
The console log is just blank when i run click on this method.
Thank you in advance for whoever helps me out
edit(), like@click="edit(49)",@click="edit(50)"?v-forand pass the index of each row toedit()as brombeer mentioned