Search code examples
extjsextjs4extjs4.1

ExtJs - Ext.createAlias in app.js


If I run:

Ext.Loader.setConfig({enabled: true}); //Why is this here?

Ext.application({
    name: 'APP',
    appFolder: 'app',
    autoCreateViewport: true,
    /*uses: [
        'APP.view.Viewport'
    ],*/
    controllers: [
        'Controller'
    ]
});

I get the following error:

[06:52:09.773] Error: [Ext.createByAlias] Cannot create an 
instance of unrecognized alias: writer.json

However, if I uncomment out the 'uses', it works fine. If I switch 'uses' for 'requires' I get the same error as above.

I feel like I shouldn't need that 'uses' but I do. I'm really confused about why I need it. I don't like having magic code.

EDIT: I have views: ['Viewport'] in my controller.


Solution

  • The error you are seeing is not related to the code you posted. Ext is trying to create json writer (because it is configured elsewhere, most likely a model or a store) but the class Ext.data.writer.Json is not declared in requires:[] of that file.

    Check all your files to find something like:

     writer:{
         type:'json'
     }
    

    and require the writer in that class.