The Vuetify expansion panel seems to be failing to reflect changes in the data

I've implemented pagination to display 5 expansion panels at a time from a list of over 60 items. However, I'm encountering an issue where the expansion panels are not updating correctly with the new lists. I am aware that a new list is being returned.

        {{this.viewFilteredTools}}
        <success-factors v-for="(x,index) in this.viewFilteredTools" :key="index" :factor="x" :tool="tool" />
        {{x}}
    </v-expansion-panels>
<v-pagination
        v-model="page"
        :length="this.paginationLength/5"></v-pagination>

This section holds the expansion panels that are received through <success-factors/>.

<script>
import SuccessFactors from './SuccessFactors.vue';
export default {
    components: { SuccessFactors },
    props:{
        tool:{
            type: Object,
            required: false,
        }
    },
    data() {
        return {
            page:1,
            paginationLength: 0,
            factors: {},
            factorsList: [],
            filterByItems: [
                {text:'A to Z (Complete Reviews First)',value:'ascending'},
                {text:'Z to A (Complete Reviews First)',value:'descending'},
                {text:'A to Z (all)',value:'allAscending'},
                {text:'Z to A (all)',value:'allDescending'}
            ],
            filterValue: {text:'Z to A (all)',value:'allDescending'},
            viewFilteredTools:[]

        };
    },
    mounted() {
        console.log('something happens here')
        this.factorsList = this.tool.factors;
        this.paginateResults(1,this.factorsList)
        this.paginationLength = this.factorsList.length
        

    },
    watch: {
        page(oldPage){
            this.paginateResults(oldPage,this.factorsList);
        }
    },
    // computed:
    async fetch() {
        const { $content} = this.$nuxt.context;
        this.factors = (await $content(this.tool['factors']).fetch());
        this.factorsList = this.tool.factors;
    },
    methods: {
        sortList(lstValue) {
            console.log(this.tool.factors);
            let sortFactors = this.tool.factors;
            sortFactors = sortFactors.sort((a,b) => {
                if(a<b){
                    return -1;
                }
                if(a>b){
                    return 1;
                }
                return 0;
            })
            this.factors = sortFactors;


        },
        paginateResults(page,results){
            console.log(results)
            const startCount = (page-1)*5;
            const endCount = startCount + 5;
            this.startCount = startCount+1;
            this.endCount = endCount;
            console.log(results.slice(startCount,endCount))
            this.viewFilteredTools =  results.slice(startCount,endCount);
        }
    }
};
</script>

this.viewFilteredTools is generated from this.factorsList within the mount lifecycle. When a new page is selected, it gets updated using the sortList() method. Although I observe changes in viewFilteredTools with every page switch, the <success-factors> component fails to receive data from the updated lists.

Answer №1

To optimize efficiency, it is recommended to utilize a computed property in Vue. By using a computed property, Vue will automatically detect when the property is updated and trigger a re-render accordingly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve every item in a JSON file based on a specific key and combine them into a fresh array

I have a JSON file containing contact information which I am retrieving using a service and the following function. My goal is to create a new array called 'contactList' that combines first names and last names from the contacts, adding an &apos ...

Ways to expand Sequelize model

Can a model be extended or inherited in order to add hooks and fields after the model has been defined? Is there a method for achieving this, similar to the following example: User = sequelize.define("user", { name: sequelize.String }); makeStateful( ...

The functionality of the function from the controller does not seem to be effective within the Angular directive

Hey everyone! I created a form using dynamic data and in the future, I will need to compile this form, fill it with data, and submit it. Here is how I built the form: <div> <form name="pageForm"> <div> <div class="form-group" ng-repe ...

Exploring function overloading in Typescript using custom types

I encountered an issue here that I believe has 2 possible solutions. Let's start with my initial implementation using function overloading: type PostgresConnectionOptions = { dialect: "postgres"; config: pg.PoolConfig; }; type MysqlConne ...

What is the best way to retrieve data from Firebase and then navigate to a different page?

I am facing an issue with my app where I have a function that retrieves data from Firebase. However, after the completion of this Firebase function, I need to redirect it to another page. The problem is that when I press the button, the redirection happe ...

The Axios call functions properly within the Vue.js mounted() hook, however it encounters issues when placed inside

Here is an example that works well: mounted(soc=1) { const data = { society: soc } axios.get('/ajax/load-centers', { data }) .then(response => console.log(response.data)) } This function is called when a certain event is successf ...

Activate the q-file toggle for the Quasar framework when a different button is selected

How can I make the file selector q-file toggle in Quasar framework when a specific button is clicked? My current attempt: When this button is clicked, it should toggle the q-file: <button @click="toggleFileSelector">Toggle File Selector&l ...

Adding date restrictions to the main method is necessary for controlling the input and output

I have a function in my react-native package that requires "from" and "to" dates as parameters. I need to implement a rule that ensures the "to" date is always after the "from" date. Where should I insert this requirement in the following code snippe ...

Order the variables in the dropdown menu based on the PHP variables

I currently have a select list that allows me to choose between two options: Popularity and Recently Ordered. My goal is to filter the objects on the page based on these attributes, connecting each option to its respective function in my dataloader.php fi ...

I wish to have the sidebar shown initially, then be able to collapse it by clicking a button and adding a dropdown feature to the side of the menu items using Bootstrap

I am looking to implement a sidebar menu using Bootstrap. I want the ability to hide the menu, even on larger screens, by clicking a button. When collapsing the menu to the left side, I want the icons to display on the left as well. Clicking on a menu i ...

Error: Babel configuration file not found

I've been working on a Vue project, but I encountered an issue right after creating it. When trying to build my project, I keep getting a parsing error: No Babel config file detected for C:\\HotelManagmet\clienthotel\babel.config. ...

We are experiencing a peculiar issue with the camera functionality in ThreeJS

I have created a scene in ThreeJS featuring two cubes, a camera, a light, and a plane. The cubes rest on the plane while the camera gracefully circles around the green cube. Despite my efforts, I am encountering an unusual issue with the camera angles. As ...

Loading SVGs on the fly with Vue3 and Vite

Currently, I am in the process of transitioning my Vue2/Webpack application to Vue3/Vite. Here's an example of what works in Vue2/Webpack: <div v-html="require('!!html-loader!../../assets/icons/' + this.icon + '.svg')" ...

Prioritize moving the JavaScript onload handler to the end of the queue

I am looking to include a JavaScript file at the very end of footer.php using a WordPress plugin. I attempted to do this with the 'add_action' Hook, but found that it is adding the JavaScript code near the </body> tag. add_action('wp_ ...

Creating an HTML Canvas effect where images are placed onto another image

Looking to create a similar effect as seen on this website () On this site, users can upload their images (4000 * 400) and have the option to add Mickey Mouse ears over their image before saving it. The Mickey Mouse ear is resizable from all four sides f ...

The operation of assigning the value to the property 'baseUrl' of an undefined object cannot be executed

I recently created a JavaScript client using NSWAG from an ASP .NET Rest API. However, I am encountering some errors when attempting to call an API method. The specific error message I am receiving is: TypeError: Cannot set property 'baseUrl' of ...

Disregard the need for synchronization with $http, but remember to consider it for

Is there a way to prevent synchronization with HTTP requests in an Angular app? I am working on a form that should be disabled while the POST request is in progress. I want to write specifications to ensure that the form remains disabled during this time. ...

Creating a filter and word replacement method in Android Studio is a useful tool for implementing text transformations

Hello there! I am currently working on developing an application that can recognize voice and convert it into text. I have successfully implemented the conversion and comparison features, but there are specific words that I need to modify or replace in the ...

Discovering whether a link has been clicked on in a Gmail email can be done by following these steps

I am currently creating an email for a marketing campaign. In this email, there will be a button for users to "save the date" of the upcoming event. I would like to implement a feature that can detect if the email was opened in Gmail after the button is cl ...

Select multiple rows by checking the checkboxes and select a single row by clicking on it in the MUI DataGrid

I am currently utilizing the MUI DataGrid version 4 component. The desired functionalities are as follows: Allow multiple selections from the checkbox in the Data Grid (if the user selects multiple rows using the checkbox). Prevent multiple selections fr ...