parallax background

What to include in app.js (Ext JS 4.x)

Digital Transformation Group LinkedIn
What’s Next After Flex? Well….Sencha!
April 11, 2012
Digital Transformation Group LinkedIn
Loading JSON data from a web service into a combobox (Ext JS 4.x)
April 26, 2012

The following should be specified above the Ext.application declaration in app.js:

Ext.Loader.setConfig({enabled:true});
Ext.require([
             'Ext.data.Store',
             'Ext.data.StoreManager',
             'Ext.data.HasManyAssociation',
             'Ext.data.BelongsToAssociation',
             'Ext.container.Viewport',
             'Ext.grid.*',
             'Ext.util.*',
             'Ext.state.*',
             'Ext.form.*'
         ]);  

Ext.application({
    name: 'Scoring',
    appFolder: 'app',
    autoCreateViewport: false,
    requires : [ 'Ext.container.Viewport'],
    ...

Why?

At some point our application stopped working in Firefox, though it continued to work in chrome. Using the ext.js library the message in Firefox was c is not a constructor and the site would fail to load.

Using the ext-debug.js library the message became the following:

Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required classes: …

After a good deal of time spent researching the internet and all related documentation, I found the following post in the Sencha forums: http://www.sencha.com/forum/showthread.php?138536-c-is-not-a-constructor-message-at-the-very-first-example/page2

To summarize the issue has something to do with resources either not be loaded or not being loaded in the correct order. Adding these requirements before the application declaration forces the various required classes to load on startup. If every JS file in your application has all the needed “Requires” statements you wouldn’t get this error, but that is rather difficult to do and in the event one of your many JS files is missing something because the error doesn’t tell you which one or in which file.

jvalentino
jvalentino
I live and work in the Dallas/Fort Worth area as a Principal Consultant for AppFoundation. I have been working with Java since 2000, Flex since it was in beta release, iOS development since 2008, and Sencha and Ext JS 4 since 2012. I have a Bachelor of Music with a double major in Music Performance and Music Composition, and a Bachelor of Science in Computer Information Science from Texas Christian University. I also have a Master of Science in Software Engineering from Southern Methodist University. I specialize in enterprise development, architecture, design, and continuous integration practices.

Comments are closed.