PDA

View Full Version : Prototype adapter does not allow executing script in dynamically loaded ContentPanels


RobbyRacoon
04-23-2007, 12:56 PM
Well, I can confirm it :) The Prototype adapter is borked in 1.0

Using the BorderLayout (I was using /ext-1.0/examples/layout/complex.html to test with), loading a ContentPanel dynamically with something like this:
Ext.Element.get(id).getUpdateManager().update({url :"/ext-1.0/examples/layout/test.html", scripts:true});
(or any of the other methods I've tried) to load a page that looks like this:
<div class="navContent">
<p onclick="alert('wth! Inline script works fine...');">Now is the time for all good men to come to the aid of their country</p>
<script type='text/javascript'>
alert( "...but script in a <Script> tag does not run" );
</script>
</div>
Using the prototype adapter the script inside the < script> block will not run, but making no other changes to complex.html except for switching the prototype adapter for the YUI adapter the script inside the < script> block will run when loaded.

Here are the includes I am using for the adapters, paths verified 1,000 times and known to be good
yui
<script type="text/javascript" src="/ext-1.0/adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="/ext-1.0/adapter/yui/ext-yui-adapter.js"></script>

prototype
<script type="text/javascript" src="/ext-1.0/adapter/prototype/prototype.js"></script>
<script type="text/javascript" src="/ext-1.0/adapter/prototype/scriptaculous.js?load=effects"></script><!--copied-->
<script type="text/javascript" src="/ext-1.0/adapter/prototype/ext-prototype-adapter.js"></script>



.

RobbyRacoon
04-23-2007, 01:30 PM
Ugh... Apparently prototype itself is the problem, since even using something like this:
new Ajax.Updater('targetDivID', 'test.php', { method: 'get' });
Results in all < script> blocks in the test.php file being stripped. What a pain!!!

According to the page at http://www.prototypejs.org/api/ajax/updater it is well known (and a conscious decision maybe?) that the script blocks are stripped from the Ajax response. Scroll down to About evalScripts and defining functions to see what I mean :/


.

Animal
04-24-2007, 09:13 AM
I can't see a reason to use the prototype-adapter. From what I've heard, prototype is well dodgy. The YUI classes upon which the yui-adapter builds are very robust.

RobbyRacoon
04-24-2007, 11:06 AM
heh. Well, though I might agree with you now that I've gotten to this point, I had not had any problems with it long enough to get a pretty significant portion of my project done :)

So now I've refactored everything to use JQuery (path of least least divergence), and everything seems to be going well for the most part. I will look into YUI after I get this project done, since this current project is comparitively small in scope and is well under way.

Oh.... Yeah... by the way.....

Ext JS Rocks!

RWaters
05-25-2007, 03:12 PM
Wow... and I thought I was going crazy... I ran into this issue and fussed around every which way I could to try and get those scripts to run.

I just stripped out all the YUI code from my rails app a little while back and this mysteriously broke, I guess I'll have to put YUI or jQuery back in then :(

jbowman
05-25-2007, 05:42 PM
I saw this the other day, maybe you'll find it useful

http://yehudakatz.com/2007/05/17/jquery-on-rails-a-fresh-approach/

Taz416
07-18-2007, 08:30 PM
I have been experimenting with Ext for a little while now and trolling the forums for info. I am one who usually searches the ends of the earth before wasting someone's time with a question that has been asked and answered so many times before. And i also believe that you gotta get dirty and "read, read, read" to learn.

I must say that the level of support to the community and the value of this product is awe inspiring to say the least.

For my part though, I would have saved a lot of time if I would have found this thread a long time ago. I was using Prototype until now. My whole project depends upon the scripts being parsed in for Ajax loads. I really think there should be a sticky on this.

Again thanks very much for your hard work. I'm sure I will be a "REAL" supporter very soon.