PDA

View Full Version : multiple .js files



Riaz
18 Oct 2010, 5:22 PM
For better management, I spilt my functionalities into multiple .js files. (example- x.js and y.js). Is it possible to call “y.js” from “x.js”?

Is there any better solution to handle .js code more manageable fashion?

evant
18 Oct 2010, 5:24 PM
Look at how the Touch library is structured. Usually 1 class per file, then communicate between classes.

Riaz
18 Oct 2010, 6:08 PM
Is there any very simple example?

ssk_hari
27 Mar 2011, 10:47 PM
Hi ... Am facing the same problem ... Can u pls share the solution for it ?

Riaz
27 Mar 2011, 10:55 PM
In x.js file


Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function () {

var myTabPanel = new Ext.TabPanel({
fullscreen: true,
items:[{xtype:'y'}]

});

myTabPanel.show();
}
});





in y.js file


myY = Ext.extend(Ext.Panel, {
:
});

Ext.reg("y", myY);



Please inform me whether it is helping you or not.

ssk_hari
28 Mar 2011, 12:58 AM
In my project, say on click on one button, I need to show a new page (like ahref) ..

So I have written a below click event of the button ...
this.body.on('click', function(){window.location.href="overhaul_inshop.html"});

But, I read that as per Sencha norms, one should have only main HTML file and other files should be only JS ...

Even in my project, I have overhaul_inshop.js file which does all operations. But, how can I give the linking now to that JS ... If it is HTML, I can call like above code ... pls advice . Thanks.

gmenuet
30 Mar 2011, 12:39 AM
Not sure to understand what you are trying to do, but if you want to include a new file to your project, you should add to your index.html file

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

Make sure you add the line after :

<script type="text/javascript" src="../libs/sencha-touch-1.0.1a/sencha-touch-debug.js"></script>

and maybe before other js file of your project.