JavaScript How to call destroy on disabled jquery widget?

Used libraries: jquery-ui-1.9.1 and jquery-1.8.2

I have one widget with some function called from destroy

$.widget("my.customwidget", {

    options: {

    },

    _destroy: function () {
        var self = this;

        this._super();
        //some usefull functionality
    },

    //some other declarations
});

If my widget was disabled, due to code in jquery-ui destroy method is not called (code from jquery-ui):

function handlerProxy() {
    // allow widgets to customize the disabled handling
    // - disabled as an array instead of boolean
    // - disabled class as method for disabling individual parts
    if ( instance.options.disabled === true || $( this ).hasClass( "ui-state-disabled" ) ) {
        return;
    }
    return ( typeof handler === "string" ? instance[ handler ] : handler )
                    .apply( instance, arguments );
            }

this handleProxy is inside of _on function. The callStack looks like so: When element with my widget is removed, $.cleanData is called. Than cleanData calls $( elem ).triggerHandler( "remove" )and trigger calls _on for remove event. Than remove calls $.widget.destroy

How can I make call to destroy function even on disabled widget?

UPDATE: Created jsFiddle for demonstration http://jsfiddle.net/9yygj1wm/

UPDATE: This is fixed in jquery-ui-1.9.2, but how it can be fixed without upgrading of a library?

Answer:1

I'm developping an angularjs (v1.2.26) application. And I used KeePass (v2.28), chromeIPass 2.6.8 (google chrome extension) to fill credentials. I got an issue with the login form: Keepass allow to ...

I'm developping an angularjs (v1.2.26) application. And I used KeePass (v2.28), chromeIPass 2.6.8 (google chrome extension) to fill credentials. I got an issue with the login form: Keepass allow to ...

Can I load jQuery migrate via RequireJS? I don't understand how the timing can be handled correctly. See this example: require([ 'jquery', 'jqmigrate' ], function ($) { if ($.browser.msie) {...}...

Can I load jQuery migrate via RequireJS? I don't understand how the timing can be handled correctly. See this example: require([ 'jquery', 'jqmigrate' ], function ($) { if ($.browser.msie) {...}...

  1. jquery migrate load

Does JWPlayer support the file source from soundcloud? <script type="text/javascript" language="javascript"> jwplayer("mainplayer").setup({ playlist: [{ ...

Does JWPlayer support the file source from soundcloud? <script type="text/javascript" language="javascript"> jwplayer("mainplayer").setup({ playlist: [{ ...

I'm using passy's angular-masonry directives to render tiled elements in my app. Unlike a lot of the masonry examples, my bricks don't include images, just static text and layout content rendered ...

I'm using passy's angular-masonry directives to render tiled elements in my app. Unlike a lot of the masonry examples, my bricks don't include images, just static text and layout content rendered ...