prototypejs - JavaScript memory loss with Prototype's Ajax.Updater? -
i'm not sure prototype specific issue, since don't have problem when not using prototype guess is.
i'm using ajax.updater append external html dom tree. in external file there script elements. since have set evalscripts options true, evaluated. when later try access objects have been set in script elements, no longer exists. example:
<script type="text/javascript"> var test = true; console.log(test); // works fine, obviously. </script> <input type="text" onkeydown="console.log(test)"> <!-- throws referenceerror exception (test not defined) when event fired. --> if request ajax.updater script element run expected, after evaluation test variable seems deleted. knows what's going on?
you can solve issue with
<script type="text/javascript"> window.test = true; // global on window console.log(test); // works fine, obviously. </script> ajax.updater call on scripts:
function evalscripts() { return this.extractscripts().map(function(script) { return eval(script) }); } since eval works locally find var test local variables of function(script) { ... }
this issue. it's issue prototype not doing global evals jquery does.
you can either hard or bump ticket.
Comments
Post a Comment