Notifications
Clear all

How can I reuse code between an actionConfig/viewConfig in object oriented fashion?

1 Posts
1 Users
0 Reactions
796 Views
0
Topic starter

ModelFormContainer's are designed to use defaultConfig, actionConfig, viewConfig, perActionConfig. However, if you implement a more specific config (actionConfig on top of defaultConfig), the code uses the most specific config and ignores other configs that apply. How can I get these configs to behave like cascading style sheets or have object-oriented behavior, where they extend each other instead of override each other?

1 Answer
0
Topic starter

This pattern will allow configs to extend each other instead of overriding each other.

DDA.ApproveOrDenyRR = Ext.extend(One.model.ModelFormContainer, {
    defaultConfig: {
      prepareFields: function(fields){
        // common prepareFields functionality

        this.prepareFieldsOther(fields);
      }
    }
    ,detailConfig: {
      prepareFieldsOther: function(fields){
        // specific detail prepareFields functionality
      }
    }
    ,actionConfig: {
      ,prepareFieldsOther: function(fields){
        // specific action prepareFields functionality
      }
    }
});