Hello,

I am running a request via Ajax.Updater with evalScripts = true and an
onComplete function.

I find that my onComplete function executes before the script content has
been evaluated. Looking through prototype.js (v. 1.5.1) this seems to be
caused by the scripts being executed as part of this line (1352):

    setTimeout(function() {html.evalScripts()}, 10);

So the onComplete function will always run first.

Besides putting a timeout in my onComplete function is there a way to make
my script run after the call to evalScripts?

Simple example showing this problem:

*File 1: index.htm*

<html>

<head>
    <script type="text/javascript" src="prototype.js"></script>
    <script type="text/javascript">
        var x = 10;
        function tellMe() {
            alert(x);
            alert(x);
        }
        function populate() {
            new Ajax.Updater("target", "content.htm", { onComplete: tellMe,
evalScripts: true });
        }
    </script>
</head>
<body>
    <a href="#" onclick="populate();">Populate</a>
    <div id="target">Content goes here</div>
</body>
</html>
**

*File 2: content.htm*

**<div>AJAX Content</div>
<script type="text/javascript">
    x++;
</script>
**

*Result*

The first alert shows 10, the second, 11.

Thanks,
Tim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to