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

Request #6672 Automtically process javascript nodes when loaded through innerHTML
Submitted: 2006-02-02 10:28 UTC Modified: 2006-02-06 22:08 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)    

 [2006-02-02 10: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


 [2006-02-04 16: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-04 19: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-04 19:58 UTC] arpad
It's not quite that simple, like I said I have some code which handles this already: 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 15: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-06 22: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 ( or most likely in the next release.