View Full Version : Desktop (example) initialize on demand

30 Sep 2009, 1:20 PM
I want to initialize the desktop on demand (via eval or something alike as the code is generated server side).

However when i eval() the code, i get an error stating MyDesktop is undefined.
However when i load the EXACT same code via <script ...> on load it works fine.
I narrowed it down to the getModules method, when i remove it the eval() doesn't generate any errors.
However the startmenu then is empty, obviously.

I also tried eval-ing the sample desktop JS that comes with Ext, same error.

Any thoughts regarding this problem?

1 Oct 2009, 8:52 AM
Now with sample code, just place this in ExtJS/examples/desktop/desktop.html, reload and watch the magic happen.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ExtTop - Desktop Sample App</title>

<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="css/desktop.css" />

<!-- GC -->
<!-- LIBS -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<!-- ENDLIBS -->

<script type="text/javascript" src="../../ext-all-debug.js"></script>

<!-- DESKTOP -->
<script type="text/javascript" src="js/StartMenu.js"></script>
<script type="text/javascript" src="js/TaskBar.js"></script>
<script type="text/javascript" src="js/Desktop.js"></script>
<script type="text/javascript" src="js/App.js"></script>
<script type="text/javascript" src="js/Module.js"></script>
<script type="text/javascript">
url : 'sample.js' ,
method: 'GET',
success: function ( result, request ) {
failure: function ( result, request) {
Ext.MessageBox.alert('Failed', result.responseText);
<body scroll="no">

<div id="x-desktop">
<a href="http://extjs.com" target="_blank" style="margin:5px; float:right;"><img src="images/powered.gif" /></a>

<dl id="x-shortcuts">
<dt id="grid-win-shortcut">
<a href="#"><img src="images/s.gif" />
<div>Grid Window</div></a>
<dt id="acc-win-shortcut">
<a href="#"><img src="images/s.gif" />
<div>Accordion Window</div></a>

<div id="ux-taskbar">
<div id="ux-taskbar-start"></div>
<div id="ux-taskbuttons-panel"></div>
<div class="x-clear"></div>


4 Oct 2009, 9:16 AM

5 Oct 2009, 11:32 PM
Still haven't been able to figure this one out :((
Any help would be greatly appreciated!!!

6 Oct 2009, 10:01 AM
Fixed it by adding the modules inside the declaration of the Desktop, and replacing 'MyDesktop' with 'this' in the getModules method.