Destroy jScrollPane

How to remove jScrollPane using destroy. Please can give a simple example for the following code:

$(document).ready(function() { $(".div1").jScrollPane(); }); <div class="div1">Some text...</div> 
+6
source share
3 answers

To destroy an instance of jscrollpane (v2):

 var element = $('.div1').jScrollPane({}); var api = element.data('jsp'); api.destroy(); 
+11
source

The old jScrollPaneRemove () function looked something like this:

 $.fn.jScrollPaneRemove = function() { $(this).each(function() { $this = $(this); var $c = $this.parent(); if ($c.is('.jScrollPaneContainer')) { $this.css( { 'top':'', 'height':'', 'width':'', 'padding':'', 'overflow':'', 'position':'' } ); $this.attr('style', $this.data('originalStyleTag')); $c.after($this).remove(); } }); } 

As you can see, this removes css or rather sets it to nothing and resets the style tag to its original styles. The problem is that the originalStyleTag is also deleted, but it looks something like this:

 $this.data('originalStyleTag', $this.attr('style')); 

Thus, this is basically a way to preserve old styles before activating jScrollPane and reapplying them when deleting jScrollPane.

A lot has changed in the new version, and I don’t know if this method still works, but it looks like this is a way to preserve the old styles before running jScrollPane, reset any css set by jScrollPane, and set the css bak to the old styles to do so as it was before jScrollPane.

It seems like a lot, and I would seriously think about trying to remove jQuery, delete, disconnect or anything else in different containers related to jScrollPane, and if all else fails, try making the above function in a script, All you really need To do this, get the old styles in the data array before running jScrollpane, and then see if the old delete function still works.

+1
source

You need to call jScrollPaneRemove () in ie $ ('. Myownscrollpane') container. jScrollPaneRemove ();

0
source

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


All Articles