I wanted to check this on each iteration of the timer. In a perfect
world the function fired by the timer would check if the element it
was about to alter is still in the dom. If not, it should clear the
timer associated with the element.

Having only one timer would kinda make the whole code as a plugin
useless. I wanted to be able to create multiple instances of the
plugin on the same page which require one timer for each element.
Guess I need to make a KYD. :(

"And you can't check for the element's
existance anywhere within the plugin code because all event handlers
have been removed with the element itself."

I don't really understand this, or it isn't at all what I experience
from testing. I have a console.log in the function fired by the timer
created by the plugin. It outputs $(this).length, which would be 1
since the plugin code attaches itself to each object supplied thru the
jQuery object. If assign my rotate-plugin to for example $('#rotate')
and then delete that same element, $(this).lenght will still output 1.
If I however console.log($('#rotate').lenght) it would respond to the
changes in the DOM.


On Nov 4, 5:30 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> You could attach a flag that the element is in use by the plugin,
> like:
>
> $(this).data('rotate',true);
>
> But in what event or how often would you check for elements with this
> flag to see if they still exist, and how would you access the internal
> interval var? It's a hard task. And you can't check for the element's
> existance anywhere within the plugin code because all event handlers
> have been removed with the element itself.
>
> To achieve this I think you need a new architecture: use a single
> timeout or interval for all elements affected by the plugin, and in
> that function you can check if the element's still there before doing
> it's thing.
>
> On Nov 4, 12:16 pm, Pom <[EMAIL PROTECTED]> wrote:
>
>
>
> > Shorthand of same question.
>
> > How do I identify the DOM-element on which a plugin has been invoked,
> > and how can I tell wheater or not it is still in the DOM or has been
> > removed?- Hide quoted text -
>
> - Show quoted text -

Reply via email to