The VueJs component refuses to display within the modal until I manually trigger a re-render by adjusting the window size

Currently, I have integrated "Carousel-3d" into my project globally by importing it like this:

import Carousel3d from 'vue-carousel-3d'
Vue.use(Carousel3d)

You can find the source and more information about it here:

After importing it, I attempted to use it within a modal window.

File: SingleStoreItem.vue

<template>
    <div>
        <carousel-3d>
             <slide v-for="index in item.images.length" :key="index-1" :index = item.images[index-1].id>
                   <img :src="item.images[index-1].src"> 
             </slide>
        </carousel-3d>
    </div>
</template>

<script>
export default {
    name: "SingleStoreItem",
    
    props: {
        item: Object
    },
};
</script>

The 'item' being referenced here is an object passed down from a parent component.

However, I encountered an issue where the carousel does not render properly within the modal. Initially, it appears like this: Modal without the carousel rendered

Strangely, when I resize the window slightly, the carousel suddenly appears correctly: Modal with the carousel rendered

Here is how I implement the modal and pass parameters to it:

<b-modal :id="item.id" size='xl' centered ok-only :title="item.name">
     <SingleStoreItem
      v-bind:item=item
     />
</b-modal>

Answer №1

Your Modal trigger may be impacting the lifecycle of your SingleStoreItem.vue component.

Without seeing the full code, especially the <script> section of the component, it's difficult for us to provide a solution.

However, it's likely that you will need to address the following:

  • The parent component's mounted or method hooks
mounted () {
    this.$nextTick(function () {
    // // Code that will run only after the
    // // entire view has been re-rendered
    })
  },

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

vue v-if="canEdit" @click.prevent

I have a Vue component called 'test' with specific template and methods. The goal is to make the div clickable only if helper.isEditable is true, otherwise it should be notClickable or touchable. However, I can only retrieve the value of helper. ...

Using AJAX to dynamically load content from a Wordpress website

Currently, I have been experimenting with an AJAX tutorial in an attempt to dynamically load my WordPress post content onto the homepage of my website without triggering a full page reload. However, for some reason, when clicking on the links, instead of ...

How does a browser decide to load content from an http URL when the frontend source is using an https URL?

When using my Vue component to load external content in an iframe, everything works fine locally. However, once I deploy it to my HTTPS site, I encounter an issue. <iframe src="https://external-site" /> Upon deployment, I receive the following erro ...

Multiple requests are being sent via AJAX

Despite numerous other posts addressing the same issue, I have not been able to find a solution for my problem. The AJAX request appears to be sent multiple times. var checkAllStatus = function () { $.ajax({ cache: false, type: "POST", ...

Tips for limiting the .click function to only the initial image in order to prevent loading all images within the container

I am facing a situation where multiple images are being returned into a specific div, which is working as intended. <div class="go" id="container"></div> Upon clicking on an image, it is loaded into a modal popup. However, instead of capturin ...

Error: Attempting to use hooks outside the scope of a function component in react-native. Hooks can only be called within the body of a

Oops! An error occurred: Invalid hook call. Hooks can only be called inside the body of a function component. There are several reasons why this might have happened: You could have incompatible versions of React and the renderer (e.g., React DOM) Your cod ...

Activate validation when the scope of a custom validator is modified

Consider a scenario where we have a custom validator with an input as the attribute's value. app.directive('inputRequired', function() { return { require: 'ngModel', scope: { inputRequired: '=& ...

"Discover the simplicity of customizing Bootstrap 5 with an easy-to-use online tool

When I was using Bootstrap 3, there was a convenient tool that allowed me to customize which features I wanted in the minified CSS/JS files to improve loading time. Now, as I delve into the documentation for Bootstrap 5, I find myself struggling to unders ...

Change the right border style for the second and third ToggleButtons in the ToggleButtonGroup

I've been working on this for a few hours now and I can't seem to get it right. Currently, I'm using Mui v5 and trying to style the ToggleButtons to look like regular MUI buttons. So far, I was able to achieve this transformation: https:/ ...

Is it possible for the versions in the package.json file to be altered

I've made updates to my package.json file - all packages are listed as follows: "dependencies": { "@apollo/client": "3.6.4", "bootstrap": "4.6.2", "graphql": "16.5.0" } ...

Storing user input in a MongoDB database using Angular and Node.js

I recently embarked on a journey to learn AngularJS, and decided to create a simple blog application to dive into MongoDB and $http requests. However, I'm facing challenges with using my Angular service to send the user-filled form data from $scope t ...

What is the best way to make a select tag read-only before the Ajax request is successful

Is there a way to make a select tag read-only before an Ajax success? I tried using this code, but it didn't work: $("#tower").prop('readonly', true); Then I tried this alternative, but I couldn't get the value from the select tag: ...

Utilize the Material UI feature to call the function

How can I pass a function as a prop to my Material UI component if the function is undefined within the component? import React, { Component } from 'react'; import styled from 'styled-components'; import InputBase from '@material- ...

Is it possible to toggle the status of an item in JSON based on a counter value

Here is the JSON data I have: "questions": { "id": 1, "question": "Select one color", "answers": [ {"id": 1, "answer" : "Green", "isSelected" : false}, {"id": 2, "answer": "Red", "isSelected" : false}, ...

Automated Scrolling Enabled in Material Design Carousel

I have been working on enhancing a carousel component using React. The client has requested an autoscroll feature, but I am concerned about potential interference with the user interface. How can I implement logic to allow users to pause or interrupt the a ...

When using the v-for directive to display all elements of an array, only the information of the clicked array should be listed when using the

I am facing an issue with my array of locations. There are 2 divs in play - one containing the list of locations and the other displaying additional info when a location is clicked. The problem arises when I click on a specific location, let's say Sc ...

Is there a way to match a string with information stored in a JSON file?

I have a snippet in my index.js that looks like this: if ('and' == trueWords) { console.log('Success!') } else { console.log('Failure!') } Below is the content of my json file: { "and": 1 } Appreciate your help! ...

Decoding json data with targeted API keys

Looking for some assistance here. I've got a JSON data set that looks like this: [ { "positive": 2, "negative": 4 }, { "positive": 9, "negative": 18 }, { "positive": 6, "negative": 12 } ...

Error: Encountered an unforeseen symbol '<' during AJAX request

I'm in the process of creating a JavaScript array to help me determine the online status of various streams. However, whenever I attempt to alert the output, I keep encountering an unexpected token '<' error at line 1 of my document. It&a ...

Why is the error message "Invalid field name: '$conditionalHandlers' in 'collaborators..$conditionalHandlers'" popping up now?

Currently, in my Node/Express/Mongoose application (latest versions), I am working on a feature that involves "Projects" with a list of "collaborators" identified by the IDS of "Users". To simplify complex aggregations, I have decided to store these IDS as ...