Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
Chnaging the data attribute inside the div doesn't change image for 360 spin view

I am using js-cloudimage-360-view.min.js to get a 360 view of images. I am getting the images perfectly, but I am unable to change the images by clicking a button.

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class = 'test' style="width: 400px; margin: 100px auto;">
        <div
        class="cloudimage-360"
        data-folder="images/"
        data-filename="{index}.jpg"
        data-amount="22"
        >
    </div>
    <div>
        <button>Click</button>
    </div>
        
    <script src="main.js"></script>
    <script src="js-cloudimage-360-view.min.js"></script>

</body>
</html>

main.js

const img_box = document.querySelector('.cloudimage-360')
const btn = document.querySelector('button')


btn.addEventListener('click',()=>{
    img_box.dataset.folder = 'temp_images/'
    img_box.dataset.filename = '{index}.png'
    console.log(img_box.dataset)
})

console.log(img_box.dataset)

Here is the folder structure

  • images
  • temp_images
  • index.html
  • js-cloudimage-360-view.min.js
  • main.js

Now in order for the 360 view to work, I have to specify the data-folder, data-filename and data-amount correctly inside the div tag and it is working fine. But I want to change the data-folder = 'temp_images/' and data-filename = '{index}.png' when the button is clicked to show a different set of images. I can see all the changes have been done correctly in the console, but the image remains the same. How can I get the images from different folders after clicking the button?

Here is the Github link

https://github.com/scaleflex/js-cloudimage-360-view

Here is a youtube tutorial

https://www.youtube.com/watch?v=uEl4Q6dG7BA&t=111s

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I suspect you'll need to destroy the component, change the attributes, and then init it again.

window.CI360.destroy();
img_box.dataset.folder = 'temp_images/';
img_box.dataset.filename = '{index}.png';
window.CI360.init();

If it still doesn't work, then it would probably be best to ask the author(s) directly.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda