Using Global variables and arrays in Extjs 4

This example will show you how to declare a global var and arrays in Extjs MVC application.

You know where to find this code :

<script type="text/javascript">
        Ext.BLANK_IMAGE_URL = '/Content/images/default/s.gif';

Global application variable :

<script type="text/javascript">
        Ext.BLANK_IMAGE_URL = '/Content/images/default/s.gif';
        Ext.MY_GLOBAL_VAR = '<?php echo $myGlobalVar; ?>'; 

Simple, right? Now you can access this variable everywhere in your mvc application.

Ext.define('', { 
	extend: '', 
	proxy: {
		type: 'ajax',
		url: 'http://'+Ext.MY_GLOBAL_VAR+'/getFolder.php'

If you need arrays , try this:

<script type="text/javascript">
        Ext.BLANK_IMAGE_URL = '/Content/images/default/s.gif';
        Ext.MY_GLOBAL_VAR_ARRAY = [ 1, 2, 3, [ 'a', 'b', 'c' ] ]; 
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

3 Responses to “Using Global variables and arrays in Extjs 4”

Trackbacks are disabled.

  • ttt says:

    are you crasy! global VAR’s since ext 1 to ext 4 never need its a dummy practice

  • AUH says:

    Exactly what I was looking for. Yes I can define singleton class and put my global vars there but sometime you need simple solution for simple problem. I needed to set value of couple of JavaScript vars from Coldfusion and did not want to go though defining class and using Ajax request to initialize vars.

  • Actually no matter if someone doesn’t understand afterward its up to other users that they will assist, so here it occurs.