<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.
On Nov 17, 7:03 pm, marlus <[EMAIL PROTECTED]> wrote:
> Hello aowie,
> im happy that you have it done!
> Can you post all your solution here?
>
> you are declaring that var myscript inside the onSuccess function?
> what i understood is that we load an js file and can call its
> functions by the id, is that correct?
>
> On 17 nov, 21:59, aowie <[EMAIL PROTECTED]> wrote:
>
> > SOLUTION!
> > Apparently there are some known bugs with Request.HTML...
>
> > responseJavascript is to be used somehow within the onSuccess, but im
> > not quite sure how...
>
> > anyways the thanks to shanebo, i was able to produce a working
> > solution
>
> > example:
> > var myScript = new Asset.javascript('/scripts/testScript.js', {id:
> > 'testScript'});
>
> > you'll need to load the Assets library in order for it to understand
> > Asset though.
> > but make sure you define your js as an asset AFTER you load your HTML
> > elements.
>
> > On Nov 17, 9:39 am, aowie <[EMAIL PROTECTED]> wrote:
>
> > > OK update on this post:
>
> > > Sorry guys i was using login.php as a module on other pages too, so i
> > > mustve taken out the js due to it not working.
>
> > > Anyways, I have made a dupe of that page with the js put back in, and
> > > it still produces the same result.
> > > I have also added both types of requests to help debug this situation.
> > > Request and Request.HTML
> > > You'll notice that if you click Request, only one instance loads in
> > > the appropriate div. But if you use the Request.HTML multiple
> > > instances load and the javascript will load on the first response
> > > after the second click, but only the first response???
>
> > > i had evalscripts set to true on the first request, but it broke it...
> > > and Request.HTML has it set to true, but no evaluation until the 2nd
> > > click.
> > > not to mention the error it returns "ob.toString is not a function".
>
> > > Let me know if you want me to add in anything else to help debug this.
> > > Thanks!
>
> > > On Nov 17, 6:04 am, "Steve Onnis" <[EMAIL PROTECTED]> wrote:
>
> > > > Are you saying there is means to be js code
> > > > inhttp://istoleyourbaby.com/login.php? Because there isnt.....
>
> > > > -----Original Message-----
> > > > From: [email protected]
>
> > > > [mailto:[EMAIL PROTECTED] On Behalf Of Oskar Krawczyk
> > > > Sent: Monday, 17 November 2008 11:00 PM
> > > > To: MooTools Users
> > > > Subject: Re: evalscripts, y u no worky?
>
> > > > Hi, you're saying the JS is "in the same page" but when I look into
> > > > login.php source there is no JS there. So what I assume you mean is
> > > > that the SECOND file you load is being stripped.
>
> > > > Well it's not – the JS file simply doesn't even load in the request –
> > > > at least that's what Firebug shows.
>
> > > > Best,
> > > > Oskar
>
> > > > On Nov 17, 4:31 am, aowie <[EMAIL PROTECTED]> wrote:
> > > > > So ive noticed that I am not the only one around here that cant get a
> > > > > correct eval response from externally loading other js scripts through
> > > > > Request or Request.HTML
>
> > > > > Ive stripped out only what is necessary for debugging purposes
> > > > here:http://istoleyourbaby.com/test.html
>
> > > > > the HTML loads perfectly but the js in the same page is stripped and
> > > > > disappears. Tis a very strange thing, and I need some fresh eyes on
> > > > > this one... mine are getting weary.
>
> > > > > The js that needs to be loaded is a simple default value filler and
> > > > > style adjuster. The js works fine elsewhere it just is getting
> > > > > stripped. So can anyone tell me if my syntax is wrong somewhere
> > > > > maybe.. or am i just missing something obvious?
>
> > > > > Any help is appreciated, thanks!