PDA

View Full Version : Call EXT function from an ordinary JS



salaccosmin
14 Sep 2009, 5:01 AM
Hi
in the a file called extjsTest.js i have

var testComWithExtJS = function (valCode){
Ext.Msg.alert('Ext call', 'OK');
}

In main.jsp i have

<script src="..../extjsTest.js"></script>

AND

<script language="JavaScript">
function testJS(code, valCode){
///////some JS code

}
</script>

I'd like to call 'testComWithExtJS' inside my fct 'testJS'.

Thnks

aconran
14 Sep 2009, 11:31 AM
Ext is standard JavaScript! You can integrate Ext with any regular JavaScript. Just make sure that you have Ext loaded and it is available when you execute it.

salaccosmin
16 Sep 2009, 11:55 PM
1. I declare in extJSFct.js

Ext.onReady(.....
var testCom = new function(code, valCode){
Ext.Msg.alert('test com', valCode);
}

///end onReady

2. im my XX.JSP i have

A. <script src="extJSFct.js"></script>
B. KO
<script language = "JavaScript">
function testCallExt(code,valCode){
Ext.onReady( function() {
Ext.BLANK_IMAGE_URL = '/extjs/resources/images/default/s.gif';
testCom(code, valCode);
});
}
</script>
C. KO
<script language = "JavaScript">
function testCallExt(code,valCode){
testCom(code, valCode);
}
</script>

What i'm dooing wrong??????
When my page are loaded, i have alert 'testCOm' bun not when i call the 'testCallExt' (IE error)

Thankx for your help

Animal
17 Sep 2009, 12:28 AM
Buy a Javascript book.

var declarations are scoped to the function that they are declared in.

You need to create a global namespace for your application using http://www.extjs.com/deploy/dev/docs/?class=Ext&member=ns and keep references to important global application objects in that.

Animal
17 Sep 2009, 12:29 AM
And STOP using IE as a development platform. It undermines productivity.

Use Firefox with Firebug.

salaccosmin
17 Sep 2009, 12:40 AM
Ok i understand. thanks again