slider: check in the destroy method if a handle actually exists or not, before calling removal functions (fixes #2987)

This commit is contained in:
Paul Bakaus 2008-06-19 11:10:41 +00:00
parent 430a0da9f6
commit 34bb6717b3

View File

@ -36,16 +36,22 @@ $.widget("ui.slider", {
this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]); this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);
}, },
destroy: function() { destroy: function() {
this.element this.element
.removeClass("ui-slider ui-slider-disabled") .removeClass("ui-slider ui-slider-disabled")
.removeData("slider") .removeData("slider")
.unbind(".slider"); .unbind(".slider");
if(this.handle && this.handle.length) {
this.handle this.handle
.unwrap("a"); .unwrap("a");
this.handle.each(function() { this.handle.each(function() {
$(this).data("mouse").mouseDestroy(); $(this).data("mouse").mouseDestroy();
}); });
}
this.generated && this.generated.remove(); this.generated && this.generated.remove();
}, },
setData: function(key, value) { setData: function(key, value) {
$.widget.prototype.setData.apply(this, arguments); $.widget.prototype.setData.apply(this, arguments);