Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
Losing data (Datatable) on a browser refresh in Vue.js

I'm trying to display data in Datatable with vuejs. What I do is that I fetch the data in store and I send it to the component to display it by Datatable. First time it works after that when I reload the page I lose all data and the table shows me that there is no data to show I don't know why. Thanks for helping me :) That's the code:

<template>
  <div class="content">
    <table id="studyLevelTable" class="studyLevelTable display table-bordered nowrap" style="width: 100%">
      <thead>
      <tr>
        <th scope="col">#Id</th>
        <th scope="col">Nom</th>
        <th scope="col">Created At</th>
        <th scope="col">Updated At</th>
        <th scope="col">Is Deleted</th>
        <th scope="col">Action</th>
      </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
  </div>
</template>

<script>
import {mapGetters} from "vuex";

export default {
  name: "displayStudyLevels",
  data: function () {
    return {
      dataTable:null,
    }
  },
  computed: {
    ...mapGetters(["getAllStudyLevels"]),
  },
  methods: {
  },
  mounted() {
    console.log("app mounted");
    this.$store.dispatch("getStudyLevels");
      this.dataTable = $('.studyLevelTable').DataTable({
        language: {
          emptyTable: "No Results Found"
        }
      });
    this.getAllStudyLevels.forEach(studyLevel=>{
      this.dataTable.row.add([
        studyLevel.id,
        '<a href="#">'+studyLevel.name+'</a>',
        studyLevel.createdAt,
        studyLevel.updatedAt,
        studyLevel.is_deleted,
        '<button class="updateButton" @click="submit">Update</button>'
      ]).draw(false)
    })
  }
}
</script>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!