I am trying to capture the selected item in a Dijit Tree widget to display the rest of the webpage. Here is the code that captures the selected item and sends it to the Django backend:
<div dojoType="dijit.Tree" id="leftTree" store="leftTreeStore" childrenAttr="folders" query="{type:'folder'}" label="Explorer">
<script type="dojo/method" event="onClick" args="item">
alert("Execute of node " + termStore.getLabel(item));
var xhrArgs = {
url: "/load-the-center-part-of-page",
handleAs: "text",
postData: dojo.toJson(leftTreeStore.getLabel(item), true),
load: function(data) {
dojo.byId("centerPane").innerHTML = data;
},
error: function(error) {
dojo.byId("centerPane").innerHTML = "<p>Error in loading...</p>";
}
}
dojo.byId("centerPane").innerHTML = "<p>Loading...</p>";
var deferred = dojo.xhrPost(xhrArgs);
</script>
</div>
The rest of the page contains HTML with dojo widgets. This is the code sent back as a “response” to the select item event. Here is a snippet:
<div dojoType="dijit.layout.TabContainer" id="tabs" jsId="tabs">
<div dojoType="dijit.layout.BorderContainer" title="Dashboard">
<div dojoType="dijit.layout.ContentPane" region="bottom">
first tab
</div>
</div>
<div dojoType="dijit.layout.BorderContainer" title="Compare">
<div dojoType="dijit.layout.ContentPane" region="bottom">
Second Tab
</div>
</div>
</div>
It displays this html response, but without dojo widgets. Is handleAs: "text" in XhrPost the culprit here?
source
share