d(this).data("draggable") is null

d(this).data("draggable") is null

Hi,

   This error occurs in firefox at the very end of a drop operation and happens 1000+ times before finishing, with everything appearing to be normal.  Looking on the web, I can find two other posts reporting an identical problem with identical situation to mine -

http://www.developerit.com/2010/06/11/jquery-live-draggable-live-droppable
http://www.jquery-board.de/index.php?t=rview&goto=1085&th=357

Looking through the jQuery UI code, I believe that the problem is in one of the methods below from jQuery UI Draggable 1.8.4, as Chrome reports  'Cannot read property 'options' of null'. Chrome also seems never to get out of the loop - I killed the tab once it reached 7000+ errors which were all the same. It seems likely that the common element to the problem in both links above, and for me, is an ajax call upon the drop? Thanks,

Colin

UPDATE: This appears to be caused, at least in my case when the draggable is removed from the DOM as part of the drop function. This seems a fairly likely use case - removal behaviour could easily be modeled as a DnD - e.g. to a trash icon, or similar.

  1. $.ui.plugin.add("draggable", "stack", {
        start: function(event, ui) {

            var o = $(this).data("draggable").options;

            var group = $.makeArray($(o.stack)).sort(function(a,b) {
                return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
            });
            if (!group.length) { return; }
           
            var min = parseInt(group[0].style.zIndex) || 0;
            $(group).each(function(i) {
                this.style.zIndex = min + i;
            });

            this[0].style.zIndex = min + group.length;

        }
    });

    $.ui.plugin.add("draggable", "zIndex", {
        start: function(event, ui) {
            var t = $(ui.helper), o = $(this).data("draggable").options;
            if(t.css("zIndex")) o._zIndex = t.css("zIndex");
            t.css('zIndex', o.zIndex);
        },
        stop: function(event, ui) {
            var o = $(this).data("draggable").options;
            if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
        }
    });