Tips for designing a Quasar page that dynamically loads content as the user scrolls

I am attempting to develop a component that will render multiple elements as the page is scrolled. I am utilizing the Quasar framework for Vue.js. Below is the code required to render a single block containing information from a JSON file:

Quasar comes with a built-in infinite-scroll component, but the examples provided only include empty elements for rendering. In my scenario, I need to render elements sequentially from an object. I have tried placing the q-infinite-scroll component within a v-for, but this has often resulted in an infinite loop.

Could someone please explain how I can modify this example to render more complex objects?

    <div v-for="(p,k) in returnProductsBySelectedType()" class='caption' :key="p.name">
                  <q-card class="my-card" flat bordered v-if="p.name !== undefined">
                    <q-item class="" >
                      <q-item-section >
                        <div class="text-body1 q-mt-sm q-mb-xs" >{{ p.name }}</div>
                      </q-item-section>
                      <q-btn flat class="bg-primary" style="width:50px; height: 50px;" color="white" :icon='includeProduct(p,k) ? "remove" : "add"' @click=' includeProduct(p) ?  removeProducts(p) : addProductToList(p)' :key="k"></q-btn>
                    </q-item>
                    <q-separator />
                    <q-item-section class="q-pa-sm bg-grey-3">
                      <div class="text-subtitle2 flex ">Calories: (Kcal) Fats: (g) Carbohydrates: (g) Protein: (g)</div>
                    </q-item-section>
                  </q-card>
                </div>

data(){
  return{
     products:json,
     dropdownType:'grains'
  }
},
methods:{
returnProductsBySelectedType(){
     let arr=[]
     for(const {type,products} of this.products){ 
       if(this.dropdownType === type ) return products
       if(this.dropdownType === 'all') arr.push(...products)
     }
     return arr
   },
}

JSON file

[
   {
      "type":"grains",
      "products":[
         {
            "id":1,
            "name":"French Baguettes"
         },
         {
            "id":2,
            "name":"Hot Dog Buns"
         },
         {
            "id":3,
            "name":"Breadcrumbs"
         },
         {
            "id":4,
            "name":"Graham Rolls"
         },
         {
            "id":5,
            "name":"Butter Buns and Croissants"
         },
         {
            "id":6,
            "name":"Mixed Onion Rolls"
         },
         {
            "id":7,
            "name":"Milk Buns"
         },
         {
            "id":8,
            "name":"Oat Buns"
         },
         {
            "id":9,
            "name":"Regular Wheat Buns"
         },
         {
            "id":10,
            "name":"Regular Wheat Buns with Whey"
         },
         {
            "id":11,
            "name":"Soy Buns"
         },
         {
            "id":12,
            "name":"Swedish Buns"
         },
         {
            "id":13,
            "name":"Wroclaw Buns"
         },
         {
            "id":14,
            "name":"Fancy Loaves"
         },
         {
            "id":15,
            "name":"Baltonian Bread"
         },
         {
            "id":16,
            "name":"Beskidzki Bread"
         },
         {
            "id":17,
            "name":"Crispy Bread"
         },
      ]
   }
]

https://i.sstatic.net/nfx32.png

Answer №1

Discover the capabilities of the Infinite Scroll feature by exploring its API documentation:

To load more data into the component, make sure to listen for the @load event which triggers when additional data is required. This can be achieved by fetching more data from a JSON file.

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

Utilizing jQuery for cloning elements

I need to add functionality for adding and deleting rows in multiple tables on my website. Currently, I am doing this by directly inserting HTML code using jQuery, but it has become inefficient due to the number of tables I have. I am considering creating ...

What is the reason behind the lack of access for modal to an external controller?

Imagine having this code in your main HTML file: <body ng-app="app" ng-controller="session as vmSession"> ... <!-- Modal content goes here --> </body> Inside the modal, you have a link: <a ui-sref="siteManagement({ site: vmSession.u ...

Moving the Promise.all feature from AngularJs to VueJs

I'm currently facing a challenge with moving a function from AngularJs to VueJs. I would really appreciate any help or suggestions you may have! items = { one: {...details here...}, two: {}, } In AngularJs: var promises = []; var deferred = $ ...

Having issues with adding elements to an array object in JavaScript

I've got some HTML code that looks like this: HTML: <INPUT TYPE=CHECKBOX NAME="clcik" onClick="add('1234','blah')" /> <input type="hidden" id="project" value="" /> JS: function add(obj1 , obj2){ var jsonAr ...

What is the best way to use CSS to evenly lay out a group of dynamically generated buttons?

My Vue-generated buttons need to be evenly laid out on the bottom of the page, with equal space on the left and right. The mdui button style I am using has fixed width and height, so I have to decide between a single row for fewer buttons (less than three ...

How to deactivate the mobile hardware back button functionality in Ionic 2

Our team has been developing a business application and we've encountered a perplexing issue. Every time we press the mobile hardware back button, our application's GUI becomes disrupted. Despite dedicating numerous hours to finding a solution, t ...

When attempting to execute a function within another function in JavaScript, a ReferenceError is triggered

I recently developed a straightforward app that utilizes the Google Drawing Library (https://developers.google.com/maps/documentation/javascript/examples/drawing-tools) to allow users to draw circles on a map. The first circle represents the source locatio ...

Sending Data to Server using Ajax and Receiving in PHP

Having some trouble with my AJAX data submission process. I can't seem to get the final value to work properly. I'm wondering if it's possible to set a PHP variable at the start of my HTML file and then use that in the AJAX post request? H ...

Organizing checkboxes to store selected values in an array using Vue.js

I am looking to implement a feature where a user can select checkboxes from a grouped list populated by an API call. When a checkbox is selected, I want to add the corresponding object to an array linked to the v-model of the checkbox input. Below are the ...

Capture the response from an AJAX request and store it in a JavaScript variable

I've been struggling to find a solution for this issue for quite some time now without any success. Here's what I'm trying to accomplish: I need to retrieve an array from my PHP file so that I can utilize it in my JavaScript code. Example. ...

Utilizing JSON and AJAX for data parsing

I have a PHP page that contains the following code: <?php $library= '{"closets":[ {"id":"001","theme":"literature","shelves": { ...

Create a bookmark system on an HTML page by utilizing the existing heading tags and implementing Javascript

Looking to implement a bookmark system using the headings within my HTML document, based on heading hierarchy. Unfortunately, my attempts have not been successful so far. https://i.stack.imgur.com/CdXjw.png I envision my bookmarks looking something like t ...

Showcasing an image stored in an HTML file on a Vue.js webpage

I'm currently facing an issue with displaying a local image saved in an HTML file on my Vue.js page. I attempted to store the content of the HTML file into a variable using the code below: computed: { compiledHtml: function() { return this.a ...

Issues with Angular functionality

I'm a newcomer to Angular and I am trying to recreate this example from jsfiddle in order to experiment with nodes. However, I am encountering issues with the Angular setup. Firstly, the jsfiddle is causing confusion because the application names do n ...

Unable to link myxins with Quasar on a worldwide scale

Encountered an issue with an 'Undefined mixin' error while attempting to utilize a mixin in a Quasar project within a Docker container view image description here comments displayed on the screen here is the specific mixin included it in both t ...

Why is webpack attempting to package up my testing files?

In my project, I have two main directories: "src" and "specs". The webpack configuration entrypoint is set to a file within the src directory. Additionally, the context of the webpack config is also set to the src directory. There is a postinstall hook in ...

Exploring the Integration of Material UI DatePicker with Firestore in ReactJS: Converting Firestore Timestamps to Date Format

The database is correctly recording the date, however, when displayed, the DatePicker does not recognize the date from the database as it is in timestamp format (seconds and nanoseconds). <DatePicker margin="normal" label="Data do pedido" ...

AngularJS: Implementing a toggle click function for a list of items within an iframe

Here's the workflow I'm dealing with: I have a collection of items, each having an ng-click event that triggers the display of an iframe below the clicked item. The process works like this: When clicking an item, a hidden div tag beneath it ap ...

Is there a way for me to retrieve the variable from one function and use it in another

I have a tool for managing images with descriptions that allows me to edit both the text and the image file. The challenge is saving the modifications I make in my database. Currently, I can only save changes if I modify the image itself. If I only update ...

The Datatable component does not display the data as expected when integrating it with Vue.js and fetching data from

Looking for a template on how to implement a Vue.js DataTable in an HTML page, fetching data from an API and including features like a search box and pagination. ...