PDA

View Full Version : ct is null while i try to initialize anExt form after jquery getScript method is run



arsh.ankur
20 Apr 2014, 11:16 PM
Hello to everyone,

I am in a learning phase, as the projects are in maintenance with Ext 3.

I have a task to auto load the js file, that contains the resources for internationalization. This is to be done on language selection. If i choose English language then the ResourceBundle-EN.js and if Chinese then the ResourceBundle-CN.js, should be loaded and after the loading of this file, a form is to be opened. Since its internationalization and has to be done on button click based on language selection, i have to load them dynamically i.e on the fly. With means of implementation, it cannot be loaded when the application is run.

For the dynamic loading of js file, I couldn't find any way to do it through the Ext's. I tried to do it with the help of javscript, but it dint work, hence i used jquery's getScript method. The code is as follows:

if(languageId=='1'){
scriptFile='/resourceBundle/ResourceBundle-EN.js';
}else if(languageId=='2'){
scriptFile='/resourceBundle/ResourceBundle-CN.js';
}

//jquery getScript method to load a script on the fly
$.getScript( scriptFile, function( data, textStatus, jqxhr ) {
load=true;
});

The jquery getScript method runs and i find the script loaded, by checking it on the browser console.

In ExtJs, is it possible to load a js file for a specific window when it gets opened and unload the script or delete the reference of the script, when the window gets destroyed.

Since the form uses the resources from the language based file, it had to be loaded first.
Now i call the Form:
I tried to call my form inside the getScript method of javascript, but found the problem "ReferenError : ct is null", then i changed the code as above and added the code to open the form as below:

while(load==false){
if(load==true){
var tabpanel = new Application.MyTestForm();
tabpanel .setHeight(400);
tabpanel .doLayout();
break;
}
}

Still its giving the same error.
Is the error because of the changing context from Ext to that of jquery?
Actually i am unable to understand, what could be the error.
Please tell me some proper way to load any js file on the fly between the execution of an application.
Am i doing some blunder or is there any other way to do it. Somebody help me out.

Thanks in advance.

Regards.