I'm moving along in my XHR project with help from the docs and the people here :} but I think I'm still missing some understanding. Any pointers in the right direction would be greate!
I have a simple "menu", the user clicks a node the connected onClick fires an XHR post and back comes my HTML which fills up my div - I am dragging records from a DB table. Now the HTML I get back includes some anchors that I want to fire when they are clicked, again firing an XHR post and so on. In short I want a very very simple paginated grid. But ... the second onClick, that is the js generated by my PHP script and returned from the original XHR doesnt get fired. I can see it in Firebug and dont see any errors. What am I missing? Here's the HTML returned from my first XHR post:
... ... ...
</table>
<script type="text/javascript">
dojo.require("dojo.parser");
var init = function(){
var mainContent = dojo.byId("main_content");
dojo.query("#PAGE_2")
.connect("onclick",
function(){
dojo.xhrPost(
{
url: "index.php/manufacturer/listRows/2",
handleAs: "text",
load: function(data,args) {
mainContent.innerHTML = data;
dojo.parser.parse(mainContent);
},
error: function(error,args) {
console.warn("error!",error);
}
}
);
}
);
</script>
<div>Pages <b>1</b><a id="PAGE_20" href="#">2</a> ... ... ...</div>

As far as I know,
As far as I know, dojo.parser.parse() is meant to parse for and create widgets, not to parse end execute javascript.
A quick search led me to this discussion: http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/dynami... , which I believe you were a part of, and leaves me a little perplexed about you posting this topic.
You say that your html and javascript is generated by a php script which grabs data from a database. What are you pulling from the DB that would require you to dynamically generate javascript. If it's only values being assigned to variables, you can easily pass those values - and even the HTML - back as a JSON object (handleAs: 'json'), and keep the javascript functions in your main script.
Can you post some of the output from your php script?
Thanks for the reply. I
Thanks for the reply. I should make my problem clearer.
I have a DB query that returns, in total, 300 rows but this number might of course vary. I want to display these 20 at a time with some typical "pagination" links at the foot of the table "1 2 ... Next", each of these links will refer to an offset or page number and each link calls my same PHP function. The links of course are generated by the PHP script and change with every subsequent call.
The code above is output of the first call to my PHP script with the data from the table removed. (The parser bit was me clutching at straws in trying to get this resolved I should have removed it before posting, sorry. And I have tried handleAs javascript with no luck.)
Googling last night has led me to lambda functions - so I got a few days of study ahead!
I guess "id='PAGE_20'" in
I guess "id='PAGE_20'" in the bottom line is a typo? If not dojo.query won't find your ancor. Do you actually call init(), because I can see only the functions declaration? Again, this could be a typo/copy&paste error, as at least the function's closing bracket is missing.
You should consider making "main_content" a dojox.layout.ContentPane and using setHref/setContent instead/within your xhrPost. Does your problem occur in all browsers or just IE? As far as I know, IE does not execute Javascript added with innerHTML.