Dojo Widgets do not appear when returned in response to XhrPost

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;
            //window.location = 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?

+3
source share
2 answers

, BorderContainer . , . dojo.parser.parse , , "centerPane" ContentPane, attr ( "", ), . , BorderContainer = "" (), .

+3

, .innerHTML DOM Dojo. , dojo.byId( "centerPane" ). ContainerNode.innerHTML =...

: dijit.byId :

dijit.byId - (id). dojo.byId, dojo.byId DOMNodes, dijit.byId JavaScript .

.

0

Source: https://habr.com/ru/post/1740443/


All Articles