tags:

views:

22

answers:

2

Hi,

I've got something similar to the following code:

$(a).click(function() {
  $(element).plugin();
});

Is there a way to remove a plugin from an element other than using $($.plugin).remove()? Not sure if I have the terminology correct but basically I want to reset the element to it's original state.

Thanks

A: 

Unless the plugin provides that functionality, it probably can not be done that easily. You'll have to investigate what the plugin does, and specifically undo those things - or store a clone of the non-plugged-in element to replace it with later.

Matchu
thanks, I'll have a look at what the plugin is doing in more detail...
Steven Cheng
+1  A: 

You'd have to know what the plugin does in order to reverse it's effects. Many plugins add extra elements to the DOM, handlers to elements, etc. If the plugin doesn't create any extra elements, you might be able to simply do a clone (without data and events) and replace or even just unbind all event handlers, but that's not always going to be effective. It would be very dependent on the plugin in question.

tvanfosson
Yep, I think the general concensus is look at the plugin first. Cheers
Steven Cheng