Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.8

Request #6672 Automtically process javascript nodes when loaded through innerHTML
Submitted: 2006-02-02 15:28 UTC
From: miguel dot manso at nfsi dot pt Assigned: arpad
Status: Closed Package: HTML_AJAX (version 0.3.4)
PHP Version: 5.1.2 OS: debian sarge 2.6.8-2-686-smp
Roadmaps: (Not assigned)    
Subscription  


 [2006-02-02 15:28 UTC] miguel dot manso at nfsi dot pt
Description: ------------ I'm trying to get my webpage to process some javascript that is loaded through HTML_AJAX. But it seems script nodes aren't automatically processed when adding them using innerHTML. Is there any chance this could be implemented in a future release? Thanx

Comments

 [2006-02-04 21:33 UTC] arpad
Are you using HTML_AJAX_Action? That's the easy method. I have some code which handles writing arbitrary HTML/JS like that, but it's currently a mixture of PHP and JS and it sounds like you need it all in JS. I'll look at porting it.
 [2006-02-05 00:36 UTC] jeichorn at php dot net
the issue is that if you have a document with a script block the script gets added to the document but it doesn't get run. The first step is to create a util method that looks for all the script tags inside a given parent element and then evals all the ones that have a type of text/javascript. Then its just a matter of adding a flag that turns on doing this automatically. This would be for HTML_AJAX_Replace etc, and possible for the HTML_AJAX_Action stuff.
 [2006-02-05 00:58 UTC] arpad
It's not quite that simple, like I said I have some code which handles this already: http://rajeczy.com/arpad/lib/index.php?p=misc/obfuscate_ajax I do think it's better done at the time of writing, otherwise you can't distinguish between scripts which have already been run and scripts being added.
 [2006-02-05 20:29 UTC] jeichorn at php dot net
HTML_AJAX action already provides a way to do it at the time of writing and its easy to tell what hasn't been run. Any newly added script blocks haven't been run. And the whole point is too make what is happening transparent.
 [2006-02-07 03:08 UTC] arpad
"looks for all the script tags inside a given parent element" made me think you were suggesting writing first and inspecting afterwards, I meant "at the time of writing" as opposed to that. I've just committed an implementation to SVN, you can find it there (http://websvn.bluga.net/wsvn/HTML_AJAX) or most likely in the next release.