« Return to Thread: Error on executing scripts from xhrPost

Error on executing scripts from xhrPost

by Matthias W. :: Rate this Message:

Reply to Author | View in Thread

Hi,
I've got some xhrPosts whose callback HTML contains JavaScript which has to be executed.

The callback HTML looks like this:

<div id="links">
 <a onclick="myDialog.open('urlString');">Link 1</a>
 ...
</div>
<div id="executionDiv" dojoType="dojox.html.test.DeclarativeContentSetter">
<script type="dojo/method">
 myDialog = new my.Dialog();
</script>
</div>

The xhrPost:

dojo.xhrPost({
  url: url,
  content: {
   ...
  },
  load: function(data){
   //targetNode.innerHTML = data;
   //dojo.parser.parse(targetNode);

   dojox.html.set(targetNode, data, {
    executeScripts: true,
    scriptHasHooks: false,
    parseContent: true
   });
  }
});

And the dojox.html.test.DeclarativeContentSetter:

dojo.declare("dojox.html.test.DeclarativeContentSetter", dojox.html._ContentSetter, {
  postscript: function() {
   this.set();
  }
});

So, this works fine in IE7 but in FF I get the error message, that myDialog does not exists by clicking the link.
How to solve this error? Thnx!

 « Return to Thread: Error on executing scripts from xhrPost