angular-ui / ui-slider

jQuery UI Slider for AngularJS
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-slider/master/demo/index.html
MIT License
265 stars 176 forks source link

smarter handling of destroy - corrects for case where it fails when in a ui-modal #78

Closed jbarrus closed 9 years ago

jbarrus commented 9 years ago

It looks like there may be a couple attempts to fix this already. I think this should cover the different use cases without errors.

The jquery slider destroy method removes the ui-slider class, so it's pretty easy to just test for that before calling destroy.

_destroy: function() {
        this.handles.remove();
        if ( this.range ) {
            this.range.remove();
        }

        this.element
            .removeClass( "ui-slider" +
                " ui-slider-horizontal" +
                " ui-slider-vertical" +
                " ui-widget" +
                " ui-widget-content" +
                " ui-corner-all" );

        this._mouseDestroy();
    },

Other issues/pull requests: https://github.com/angular-ui/ui-slider/issues/41 https://github.com/angular-ui/ui-slider/pull/75