jscroll icon indicating copy to clipboard operation
jscroll copied to clipboard

Multiple jscrolls && Exposed destroy API

Open breezern opened this issue 8 years ago • 2 comments
trafficstars

Hi, this is a convenient, small and exquisite plugin.But i get some issues here.

First,i want to set multiple jscrolls within a tab plugin, there is only one jscoll instance displayed at the same time , so i have to set .jscroll{ overflow-y: scroll; height: xxxpx;} in my CSS file. But i do not want to set a fixed height for my jscroll instance.

Then, i get an idea that , when i set a tab to be active , i can destroy the old one and create a new one.But i find that the exposed destroy() API does not work.

_destroy = function() {
    return _$scroll.unbind('.jscroll')
                    .removeData('jscroll')
                    .find('.jscroll-inner').children().unwrap()
                    .filter('.jscroll-added').children().unwrap();
 }

So i go to read the code, if _$scroll === $(window), there are two issues.

  1. .data('jscroll') is bind to $e, so .removeData('jscroll') does not work.
  2. $(window).find('.jscroll-inner') returns [].

So i change some lines:

_destroy = function() {
                $e.removeData('jscroll')
                    .find('.jscroll-inner').children().unwrap()
                    .filter('.jscroll-added').children().unwrap();
                return _$scroll.unbind('.jscroll');                    
 }

Now, i want to know is there some side effect ?

Thanks, breezern

breezern avatar Nov 28 '16 08:11 breezern

I was also having issues with the .destroy() method and had reverted to using .data('jscroll',null) which caused different issues - i altered my destroy() function to match breezern's changes above and started using the .destroy() method and it appears to be working well -

Thank you!

mkoch42 avatar Jan 15 '17 15:01 mkoch42

Hii

I am getting not a function error on ".jscroll().destroy();". What is the issue?

viksharma31 avatar Feb 08 '17 12:02 viksharma31