views:

21

answers:

2

Hi,

i have the following form item

{
 fieldLabel:'Username'
,id:"username"
,name:'username'
,allowBlank:false
,plugins:[Ext.ux.plugins.RemoteValidator]
,rvOptions: {
    url:'/registration/member/valid-username'
}

is it possible to remove plugins later via code?

+1  A: 

I don't think so. init in the plugin runs when the component is initialized, so "later in the code" it's too late - "the damage has been done", and the plugin has hooked into the component's events, etc. It would be cool if I were wrong.

Jonathan Julian
A: 

Well, it's functionally possible to support plugin deactivation (not sure about actually removing the plugin altogether), but most plugins probably don't do so unless they have some reason to support it. You should be able to write an override to the plugin and insert code that would allow you to activate/deactivate its functionality. Depends on the specific plugin of course, but if the plugin is well-written it should be overrideable.

My general approach would be something like:

Ext.override(Ext.ux.plugins.SomePlugin, {
   isActive: true,
   doSomething: function(){
      if(this.isActive){
          // copy orig doSomething
      }
   }
});

Then you could simply set pluginInstance.isActive = true/false as needed. Note that this is simplistic -- your plugin might take a lot more work to override effectively. But this approach would be a good place to start.

Or you could maybe get fancy and use createInterceptor functions on the plugin to do something similar without duplicating code.

bmoeskau