Skip to content

Commit

Permalink
Added the destroy() method to the public API.
Browse files Browse the repository at this point in the history
This is a way to remove undo the jScrollPane method

Signed-off-by:  <blackjid>
  • Loading branch information
unknown committed Oct 29, 2010
1 parent 9ef95f7 commit d3cdee3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions script/jquery.jscrollpane.js
Expand Up @@ -974,6 +974,15 @@
}
)
}

function destroy(){
if(isScrollableH) horizontalBar.remove();
if(isScrollableV) verticalBar.remove();

pane.children().unwrap().unwrap();
elem.removeClass("jspScrollable").removeAttr("style").removeAttr("tabindex").removeData("jsp");
elem.unbind('.jsp');
}

// Public API
$.extend(
Expand Down Expand Up @@ -1103,6 +1112,11 @@
hijackInternalLinks: function()
{
hijackInternalLinks();
},
// It simple distroy a the jscrollpane for that element.
destroy: function()
{
destroy();
}
}
);
Expand Down

1 comment on commit d3cdee3

@aivopaas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be improved.

.removeAttr("style").removeAttr("tabindex")
This should instead restore previous values if there were any

Also pane.children().unwrap().unwrap() could be improved. For example, pane.children().detach().appendTo(elem.empty());

Or probably even make a var clone = elem.clone().empty(); when initializing so that it keeps all the original attributes and then just elem.replace(clone.append(pane.children()));

Please sign in to comment.