Threaded View

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    27
    Vote Rating
    0
    Answers
    3
    arcan9ne is on a distinguished road

      0  

    Question Answered: Ext.application and Ext.override in launch function does not work?

    Answered: Ext.application and Ext.override in launch function does not work?


    I'm moving towards the ExtJS 4.0 MVC architecture and I had an override in my old init method which worked:

    Old code that worked:
    Code:
    APP.app = function() {
    ...
      return {
        init: function() {
          Ext.QuickTips.init();
          
          Ext.override(Ext.Ajax.request, {
            extraParams: {
              param_1: Ext.get('my_id').getValue(),
              param_2: Ext.get('my_id_2').getValue(),
              param_3: Ext.get('my_id_3').getValue()
            }
          });
        }
      }
    }
    
    Ext.onReady(APP.app.init, APP.app);
    New code that doesn't
    Code:
    Ext.application({
      name: 'APP',
      autoCreateViewport: true,
      launch: function() {
        Ext.override(Ext.Ajax.request, {
          extraParams: {
            param_1: Ext.get('my_id').getValue(),
            param_2: Ext.get('my_id_2').getValue(),
            param_3: Ext.get('my_id_3').getValue()
          }
        });
      }
    });
    As you can see, I've moved this override to the launch function. You will also realize that I am retrieving my values from elements in the page after it has been loaded which is the reason for applying the override in the launch function.

    Any help would be much appreciated.

  2. I got it working: I've moved the above code with the Ext.override directive to the launch function of the application, like you did:
    Code:
    Ext.application({
      ...
      launch: function() {
        Ext.data.proxy.Server.override({
          ...
        });
        ...
      }
    });
    First, it did not work either. Then I switched the ExtJS library from ext.js to ext-debug.js in the HTML header:
    Code:
    <script src="extjs/ext-debug.js" type="text/javascript"></script>
    And it magically worked!

    So I guess, in order to use ext.js again (for the final apllication version), there is something missing, maybe one has to require a specific class, which I'm not aware of?

Thread Participants: 2