dojo/dijit ContentPane setting content

Posted by Kitson on Stack Overflow See other posts from Stack Overflow or by Kitson
Published on 2010-03-08T16:39:56Z Indexed on 2010/03/16 9:36 UTC
Read the original article Hit count: 509

Filed under:
|
|
|

I am trying append some XML retrieved via a dojo.XHRGet to a dijit.layout.ContentPane. Everything works ok in Firefox (3.6) but in Chrome, I only get back 'undefined' in the particular ContentPane.

My code looks something like this:

var cp = dijit.byId("mapDetailsPane");
cp.destroyDescendants(); // there are some existing Widgets/content I want to clear
                         // and replace with the new content

var xhrData = {
  url : "getsomexml.php",
  handleAs: "xml",
  preventCache: true,
  failOk: true
};

var deferred = new dojo.xhrGet(xhrData);
deferred.addCallback(function(data) {
  console.log(data.firstChild); // get a DOM object in both Firebug 
                                // and Chrome Dev Tools
  cp.attr("content",data.firstChild); // get the XML appended to the doc in Firefox,
                                      // but "undefined" in Chrome
});

Because in both browsers I get back a valid Document object I know XHRGet is working fine, but there seems to be some sort of difference in how the content is being set. Is there a better way to handle the return data from the request?

There was a request to see my XML, so here is part of it...

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" 
 xmlns="http://www.w3.org/2000/svg" 
 xmlns:xlink="http://www.w3.org/1999/xlink" 
 version="1.1" width="672" height="1674">
 <defs>
   <style type="text/css">
     <![CDATA[ ...bunch of CSS...
     ]]>
   </style>
   <marker refX="0" refY="0" orient="auto" id="A00End" style="overflow: visible;">
   ...bunch more defs...
 </defs>
 <g id="endpoints">
   ...bunch of SVG with a some...
   <a xlink:href="javascript:gotoLogLine(16423,55);" xlink:type="simple">...more svg...</a>
 </g>
</svg>

I have run the output XML trough the WC3 validator for XML to verify it is valid. Like I said before, works in FireFox 3.6. I tried it on Safari and I got the same "undefined" so it seems to be related to Webkit.

© Stack Overflow or respective owner

Related posts about dojo

Related posts about dijit