g0ldsteinsbr0
g0ldsteinsbr0

Reputation: 249

Migrate from extJS 4 to extJS 5 : property undefined

While trying to update my application from ExtJS4 to ExtJS5, I went into this error :

Uncaught TypeError: Cannot read property 'get' of undefined 

With the following code :

Ext.onReady(function () {
    Ext.require([
        'Ext.util.Cookies'
    ]);
    top.Dictionary.setDictionary(fr_FR);

    var formUserNameValue = "";
    if (Ext.util.Cookies.get('userName')) { <<<< the error occurs here
        formUserNameValue = Ext.util.Cookies.get('userName');
    }

And the index.html page :

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>Login</title>

<!-- Importation ExtJS -->
<script type="text/javascript" src="../../ext-5.0.0/ext-debug.js"></script>
<link rel="stylesheet" href="../../ext-5.0.0/packages/ext-theme-neptune/build/resources/ext-theme-neptune-all.css"/>

<script type="text/javascript" src="app.js"></script>

<!-- Importation des dictionnaires -->
<script type="text/javascript" src="dictionary/fr_FR.js"></script>
<script type="text/javascript" src="dictionary/en_EN.js"></script>

Do you have any idea where that could come from ?

Upvotes: 2

Views: 1255

Answers (1)

Saki
Saki

Reputation: 5856

Ext.require is asynchronous, i.e. it sends the request to the server and returns immediately. You have two options, first it better if it works:

  1. move Ext.require before onReady
  2. use Ext.syncRequire

Upvotes: 1

Related Questions