0

Once the page load, code is working fine, after trying to change the set of images through ajax within same div, without refreshing the page, then zoom is not working

I assigned a variable and set the zoom, then disable the zoom using destroy method, then again enabled the zoom..

    $(function(){
    var zoom;
     zoom = $(".rtwpvg-wrapper").find("img").magnify();
     $(".swatchinput").each(function(){
         $(this).click(function(){
            zoom.destroy();
            $(".rtwpvg-wrapper").find("img").magnify();
         });
     });
});

zoom Images should work even after replacing the images within same div

Rajan Sharma
  • 2,211
  • 3
  • 21
  • 33
Nischinth
  • 21
  • 1
  • 2
  • How is the HTML structured and which elements are replaced by JavaScript? – showdev Jul 30 '19 at 06:24
  • Hello, here I am sharing the demo link, please check this link, after selecting the size, imagezoom is not working https://www.mediajenie.com/demosites/tonirossi/product/maverick/ – Nischinth Jul 30 '19 at 06:29
  • It might help to include a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that demonstrates the issue in your question. – showdev Jul 30 '19 at 06:36

1 Answers1

0
window.imageZoom.kill();
window.imageZoom = new ImageZoom(container,options);
Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
  • 3
    While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Kevin M. Mansour Jul 13 '21 at 22:07