<html>
<head>
<script type="text/javascript" src="scripts/mootools.js"></
script>
<script type="text/javascript" src="scripts/mootools-1.2-
more.js"></script>
<script language="javascript">
window.addEvent('domready', function() {
var showLogin2 = new Request.HTML({ //loads sign in form
url: 'logintest.php',
evalScripts: true,
onSuccess: function(responseTree, responseElements, responseHTML,
responseJavaScript) {
$('formContainer').set('html', responseHTML);
var myScript = new Asset.javascript('/scripts/testScript.js',
{id: 'testScript'});
},
onFailure: function() {
$('formContainer').set('text', 'The request failed.');
}
});
$('loginLink2').addEvent('click', function(e){
e.stop();
showLogin2.send();
});
});
</script>
</head>
<body>
<a id="loginLink2" href="#">Request.HTML</a>
<div id="formContainer"></div>
</body>
</html>
the example in my last post came straight out of the mootools docs
found here:
http://mootools.net/docs/Plugins/Assets
although the properties, such as id, arent necessary for making it
work.
I took the liberty of doing a test with a function i've created in the
externally loaded js. So far I have not found how to reference
functions within the new Asset. I've tried the following with no
success:
function written to the Asset file:
function tester(){
alert('blah');
}
tested (but failed):
myScript.tester(); <---the var associated to the js file
testScript.tester(); <-- the id set in the properties of the js file
tester(); <-- plain function call
i have also tried referencing a simple var that was defined in the
external js with the same methods as above.. the var is recognized..
but the output is undefined.
FYI all of these methods were tested directly AFTER the js was loaded
(a.k.a the next line down)
So youd think it would work right? ...wrong. What good is having an
Asset you can't use??!?!?!
I think the docs for mootools needs to get a serious revamping, most
everything in there is so generic and less in depth than Carrot Top's
jokes
Anyways, let me know if anyone figures out how to call to functions
within a defined Asset.