Hi Stju, the error your having might be related to cache?
This is for code embed style or code ondemand, might help someone, what i did is to create a DOM element for a childSandbox bridge, with eval in it.. ill try to digg in to the codes since im in Titanium now.
heres how i got it.. the Childsandbox script, i named it ChildSandbox, the Namespace is just like Ext.ns
Code:
/**
* ChildSandbox
*
* @author khebs
* @email khebs@live.com
* @date December 10, 2009
* @version 0.1a
* @singleton
*
*/
Namespace('Base.ChildSandbox');
Base.ChildSandbox = {
/**
* The IFRAME Dom Element
* @type object
*
*
<iframe id="sandbox"
style="display:none"
sandboxRoot='http://www.example.com/'
documentRoot="app:/"
allowCrossDomainXHR="true"></iframe>
*
*/
dom: Ext.DomHelper.append(Ext.getBody(), {
id: 'child-sandbox',
tag: 'iframe',
style: 'display:none;',
sandboxRoot: 'http://www.example.com/',
src: 'Base/assets/child.html',
documentRoot: 'app:/',
allowCrossDOmainXHR: 'true'
}),
/**
* Get Bridget ChildSandBoxBridge
* @public
*/
getBridge: function()
{
return this.dom.contentWindow.childSandboxBridge;
}
};
and then you will need the the html for the childsandbox, child.html
Code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../libraries/frameworks/ext/release/ext-base.js"></script>
<script type="text/javascript" src="../libraries/frameworks/ext/release/ext-all.js"></script>
<script>
var bridge = {
eval: function(source, scope)
{
try {
return eval.call(scope, source);
} catch(e) {
return e;
}
}
};
window.childSandboxBridge = bridge;
</script>
</head>
<body>
TODO write content
</body>
</html>
And how to execute the code..
Code:
// Specify Handlers for Success & Failure
var success_handler = Base.util.isDefined(config.success) ? config.success : function(){};
var failure_handler = Base.util.isDefined(config.failure) ? config.failure : function(){};
// Call Ajax Request
Ext.Ajax.request({
method: 'POST',
url: Base.Module.System.Preferences.Data.API_ADDRESS,
// onSuccess Event Handler
success: function(r)
{
var result = r.responseText;
// bind the resulting
DirectAPI.API.provider = Base.ChildSandbox.getBridge().eval(result);
try
{
// Add a Direct API, accessable using DirectAPI.API.<API>
Ext.Direct.addProvider(DirectAPI.API.provider);
// Bind Exception Event Listener
Ext.Direct.on('exception', function(e){
MessageBox.show({
title : 'DirectAPI Exception',
msg : Ext.encode(e),
icon : MessageBox.MINUS
});
failure_handler(config, 'Trace Error: ' + e);
});
// Calls the Success Handler
success_handler();
}
catch(err)
{
// Calls the Failure Handler when catched error
failure_handler(config, err);
}
},
// onFailure Event Handler
failure: function(r)
{
// Calls the Failure Handler when catched error
failure_handler(config, r.responseText);
}
});
There is a better way "maybe" but for now, this codes just works..
Hope this helps..