jQuery destroy method doesn't remove instance data on element
RomanAkhma opened this issue · 3 comments
RomanAkhma commented
How to reproduce:
// initialize
$('.sidebar').stickySidebar();
// destroy
$('.sidebar').stickySidebar('destroy');
// initialize again
$('.sidebar').stickySidebar(); // ... and nothing happens
You can't reinitialize StickySidebar because $('.sidebar').data('stickySidebar')
contains previous instance;
.stickySidebar('destroy')
method should delete previous data;
piotrfonte commented
I’m getting a similar issue in vanilla javascript world when working with Swup—have to destroy stickySidebar on each page load, but it fails.
aykutyilmaz37 commented
i have this problem. have a solution?
jellehermsen commented
You can just use jQuery's removeData function to get rid of the Sticky Sidebar data. Afterwards you're able to re-initialize it at your convenience.
$('.sidebar').stickySidebar('destroy');
$('.sidebar').removeData('stickySidebar');