I have a table that could potentially be populated with any number of rows (e.g. 3, 3800, etc.), so before the data is populated, I want to apply an overlay (I already have a function applyOverlay()
for that). Here's my HTML:
<table id="table" class="datatable" style="width:100%">
<thead>
/* table header */
</thead>
<tbody>
<tr v-for="(item, index) in items" item="item">
<td v-text="item.Name"></td>
/* more <td> */
</tr>
</tbody>
</table>
And here's my JavaScript:
var tblItems = [ /* items */ ];
var app = new Vue({
el: '#table',
data: {
items: tblItems
}
});
I tried using jQuery's $(document).ready
, but I see that the page gets loaded (table not populated yet), and my overlay isn't applied until seconds later (and the table is populated). I want to have the overlay applied as soon as the html is done loading. I read about their lifecycle but I'm not sure which hook I should use. My applyOverlay()
is vanilla JavaScript and doesn't depend on Vue.
EDIT: I've tried using mounted
, beforeMount
, created
, and beforeCreate
, and nothing has worked. I wonder if it has anything to do with jQuery. But, my jQuery does load first before loading Vue.