Can't get the destroy() method of a jQuery UI plugin to work (+conflicting jQuery plugins)

泄露秘密 提交于 2019-12-04 08:24:53

Most jQuery plugins store the new instance of their object within jQuery data. I took a peak at what I think is the royal slider code - http://dimsemenov.com/plugins/royal-slider/ - and I think that you could destroy it by directly referencing the royalSlider object.

First you're going want to check and see if the element you're trying to call destroy on actually has a royalSlider instance.

console.log($(prevLocation).data('royalSlider'));

Assuming the line above returns an object, you should then be able to access the destroy method directly. If it doesn't return an object, then either you're calling destroy on the wrong element, or something else is blowing away the stored instance.

$(prevLocation).data('royalSlider').destroy();

I tested this at the royalSlider website by typing the following into my console

$('#homeSlider').data('royalSlider').destroy();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!