Would we be able to pass in a number of variables to the functions
such as show and hide which are initialised outside of the closures,
rather than store references to the "this" object.

I attempted to refactor/modify the code as a quick test but I kept
getting null references to things like the title when attempting to
show the cluetip even though I was passing in things such as titles
etc directly.

On Oct 27, 11:11 pm, Karl Swedberg <k...@englishrules.com> wrote:
> thanks for that explanation, Dave.
>
> --Karl
>
> On Oct 26, 2009, at 7:54 PM, Dave Methvin wrote:
>
>
>
>
>
> > I think a lot of plugins have this problem but most people aren't
> > creating and deleting them a lot. My splitter has this issue but I
> > solved that problem because I was too lazy to support splitters being
> > destroyed. See, the real problem is that you have a "destroy"
> > option!  :-)
>
> > Since $this and other vars like $cluetip are being used within several
> > of the event handlers by closure, the jQuery (and DOM) objects they
> > contain are kept alive. You can't delete or null them out because
> > they're used while the cluetip is active. Those handlers would need to
> > be rewritten to use the local "this" instead and I think the handlers
> > need to be declared outside the .each() function scope. You'd have to
> > do the same with all the other cached variables like $cluetip as well.
> > In addition to destroy detaching all the event handlers, it should
> > remove any .data() or .metadata() that was put onto the element. The
> > jQuery UI widgets have a destroy pattern, you can see how they do it.
>
> > I also see a leak like the one discussed here:
>
> >http://groups.google.com/group/jquery-dev/browse_frm/thread/2b1981f75...
>
> > If you use any "modifying" operation in a chain and save the later
> > part of the chain in a variable, the older part of the chain is still
> > referenced by jQuery's .prevObject property. I can see some of those
> > in the cluetip plugin:
>
> > $dropShadow = $([]);
> > for (var i=0; i < dropShadowSteps; i++) {
> >   $dropShadow = $dropShadow.add($('<div></div>').css({zIndex:
> > cluezIndex-1, opacity:.1, top: 1+i, left: 1+i}));
> > };
>
> > The .add() method creates a new object each time through the loop but
> > the older objects are retained as a chain of .prevObject properties
> > leading from the jQuery object held by the final $dropShadow variable.
> > As long as the $dropShadow variable goes out of scope when the
> > function is done at the end of the .each() call to that function, it
> > should be reclaimed. At the moment $dropShadow is kept alive by the
> > cluetipshow event handler so the whole chain can't be garbage
> > collected.- Hide quoted text -
>
> - Show quoted text -

Reply via email to