From 34bb6717b30d66f6e9e75a7181b9b86f76a35874 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Thu, 19 Jun 2008 11:10:41 +0000 Subject: [PATCH] slider: check in the destroy method if a handle actually exists or not, before calling removal functions (fixes #2987) --- ui/ui.slider.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/ui.slider.js b/ui/ui.slider.js index ad701ccc0..ad15cc04b 100644 --- a/ui/ui.slider.js +++ b/ui/ui.slider.js @@ -36,16 +36,22 @@ $.widget("ui.slider", { this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]); }, destroy: function() { + this.element .removeClass("ui-slider ui-slider-disabled") .removeData("slider") .unbind(".slider"); - this.handle - .unwrap("a"); - this.handle.each(function() { - $(this).data("mouse").mouseDestroy(); - }); + + if(this.handle && this.handle.length) { + this.handle + .unwrap("a"); + this.handle.each(function() { + $(this).data("mouse").mouseDestroy(); + }); + } + this.generated && this.generated.remove(); + }, setData: function(key, value) { $.widget.prototype.setData.apply(this, arguments);