JQuery - remove a function attached to a div

I ran into a problem with jQuery , so I think I figured out a workaround, but I need help.

I am currently attaching a loop slide show () to my div as follows:

function startSlideshow() {
    $('#slideshow').cycle({ some parameters });
}

When I pause and restart this slide show, it detects strange behavior due to errors in the loop plugin. So my workaround is this: destroy the existing loop () and then just recreate it on the fly.

I can easily recreate it by calling startSlideshow () again ... but how can I kill the old loop () attached to the div?

I suppose I'm looking for a way to completely “undo” or “untie” it (and the jQuery unbind () method is wrong).

Thanks-- Eric

0
source share
3 answers

Use the destroy plugins command, it is added in version 2.80

$('#slideshow').cycle('destroy');
+2
source

you can use $('#slideshow').cycle('destroy');

But are you sure that the strange behavior is due to the fact that the loop plugin has errors? and not its misuse?

How did you pause and restart the bike?

+2
source

First you delete the attached loop command. Then you remove the inline styles created by the loop:

$("#slideshow").cycle("destroy");
$("#slideshow, #slideshow *").removeAttr("style");
startSlideshow(); // recreate cycle slideshow
+1
source

Source: https://habr.com/ru/post/1755429/


All Articles