#101 enhancement
tsveg1

Ajax.Request: scripts not eval in the global scope

Reported by tsveg1 | May 15th, 2008 @ 10:31 AM | in 1.6.1

The problem is in an Ajax.Request Call.

In the evalScript Function javascripts are evaluated locally and not on the page (DOM). If I've got same new script in Response they are not correctly evaluated.

evalScripts: function() {

return this.extractScripts().map(function(script) { return eval(script) });

Suppose I define a new variable script (var dummy = 10). This code doesn't work because the script is not evaluated on the dom (an example is popup component in tomahawk jsf component).

The possible correction is:

evalScripts: function() {

return this.extractScripts().map(

function(script)

{

try {

if (window.execScript) { // Eval correctly in IE return window.execScript(script);

} else { // Eval correctly in FF

return window.eval(script);

}

} catch (e)

{}

}

);

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket