Hi,

There is a ticket for this:
http://dev.rubyonrails.org/ticket/7826

and was posted to this group: 
http://groups.google.com/group/prototype-core/browse_thread/thread/b10d5a4c89302fc

I don't know why it hasn't been fixed though.

The solution for me was putting the call to onComplete inside a
timeout, as you said.

Bernardo

On Nov 19, 1:01 am, "Tim Carpenter" <[EMAIL PROTECTED]>
wrote:
> 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 [email protected]
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