Loading ...
Sorry, an error occurred while loading the content.

Really need help here...one more try

Expand Messages
  • John
    Here is my current problem: I think I figured out how to change a node from an Edit button...my form appears anyway, but the positioning within the node is
    Message 1 of 4 , Apr 2, 2008
    • 0 Attachment
      Here is my current problem:

      I think I figured out how to change a node from an Edit button...my form appears anyway, but the positioning within the node is off. Here is a sample of my code I am using:

      function updateNodeData(nodeLabel, edit) {
              var node = getNodeByLabel(nodeLabel);
              var editMod = ((edit == "true") ? "&editMod=true" : "");
              
              if(node) {
                  var nodeLabel = encodeURI(node.label);
                   var patientId = <ww:property value="model.id" escape="false" />;
                  var sUrl = "NPSModuleAjaxResponse.action?query=" + nodeLabel + "&pat=" + patientId + editMod;

                  var callback = {
                      success: function(oResponse) {
                          YAHOO.log("XHR transaction was successful.", "info", "example");
                         
                          var oResults = eval(oResponse.responseText);
         
                          node.getChildrenEl().innerHTML = oResults;
                         
                          oResponse.argument.fnLoadComplete();
                      },
                      failure: function(oResponse) {
                          YAHOO.log("Failed to process XHR transaction.", "info", "example");
                          oResponse.argument.fnLoadComplete();
                      },
                      argument: {
                          "node": node,
                          "fnLoadComplete": node.loadComplete
                      },
                      timeout: 7000
                  };
                  YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
              }
              else {
                  alert("Not working!");
              }
          }
         
          // Find the node in the tree based on the label.
          function getNodeByLabel(label)
          {
              var node = null;
              var found = false;
              var index = 1;
              do
              {
                  node = tree.getNodeByIndex(index++);
                  if(node != null && node.label != null && node.label == label)
                      found = true;
              }
              while(node != null && !found);
              return node;
          }

      These functions work, sort of. The node changes from it's original data to the new data, but there is an error that happens in the javascript on the treeview.js page. The error is the following from Firebug:

      this.getChildrenEl is not a function
                          this.getChildrenEl().innerHTML = this.completeRender();

      Any thoughts on this?

    • Fiouz
      Hi, ... You must give the function as a closure because the node scope isn t held by the actual loadComplete function: fnLoadComplete : function () {
      Message 2 of 4 , Apr 2, 2008
      • 0 Attachment
        Hi,

        On Wed, Apr 2, 2008 at 6:14 PM, John <brjelder@...> wrote:
        > argument: {
        > "node": node,
        > "fnLoadComplete": node.loadComplete
        > },

        You must give the function as a closure because the "node" scope isn't
        held by the actual loadComplete function:

        "fnLoadComplete": function () { node.loadComplete(); }

        Another way is to define the "scope" attribute [1] so that "this"
        refers to "node" in order to directly call "this.loadComplete()":

        var callback = {
        /* ... */
        success: function (oResponse) {
        /* ... */
        this.loadComplete();
        },
        scope: node
        };

        [1] http://developer.yahoo.com/yui/connection/#scope

        Regards,

        --
        Fiouz
      • John
        Thanks for the reply. I added the scope and called this.loadComplete(), however that acts exactly like node.loadComplete(). What this does is instead of
        Message 3 of 4 , Apr 2, 2008
        • 0 Attachment
          Thanks for the reply.

          I added the scope and called this.loadComplete(), however that acts
          exactly like node.loadComplete(). What this does is instead of changing
          the existing node, it appends the new version right below the version I
          want to replace.

          What I need it to do is to replace the old node.

          This is what my new code looks like:

          function updateNodeData(nodeLabel, edit) {
          var node = getNodeByLabel(nodeLabel);
          var editMod = ((edit == "true") ? "&editMod=true" : "");
          if(node) {
          var nodeLabel = encodeURI(node.label);
          var patientId = <ww:property value="model.id" escape="false" />;
          var sUrl = "NPSModuleAjaxResponse.action?query=" + nodeLabel +
          "&pat=" + patientId + editMod;
          var callback = {
          success: function(oResponse) {
          YAHOO.log("XHR transaction was successful.", "info",
          "example");
          var oResults = eval(oResponse.responseText);
          if(YAHOO.lang.isArray(oResults)) {
          for (var i=0, j=oResults.length; i<j; i++) {
          var tempNode = new
          YAHOO.widget.TextNode(oResults[i], node, false);
          }
          } else {
          var tempNode = new
          YAHOO.widget.HTMLNode(oResults.toString(), node, false, false);
          }
          this.loadComplete();
          },
          failure: function(oResponse) {
          YAHOO.log("Failed to process XHR transaction.", "info",
          "example");
          oResponse.argument.fnLoadComplete();
          },
          argument: {
          "node": node,
          "fnLoadComplete": node.loadComplete
          },
          scope: node,
          timeout: 7000
          };
          YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
          }
          else {
          alert("Not working!");
          }
          }

          I also realized that node.getChildrenEl().innerHTML = oResults; did not
          work at all. I replaced it with:
          if(YAHOO.lang.isArray(oResults)) {
          for (var i=0, j=oResults.length; i<j; i++) {
          var tempNode = new
          YAHOO.widget.TextNode(oResults[i], node, false);
          }
          } else {
          var tempNode = new
          YAHOO.widget.HTMLNode(oResults.toString(), node, false, false);
          }

          Any thoughts?

          --- In ydn-javascript@yahoogroups.com, Fiouz <fiouzy@...> wrote:
          >
          > Hi,
          >
          > On Wed, Apr 2, 2008 at 6:14 PM, John brjelder@... wrote:
          > > argument: {
          > > "node": node,
          > > "fnLoadComplete": node.loadComplete
          > > },
          >
          > You must give the function as a closure because the "node" scope isn't
          > held by the actual loadComplete function:
          >
          > "fnLoadComplete": function () { node.loadComplete(); }
          >
          > Another way is to define the "scope" attribute [1] so that "this"
          > refers to "node" in order to directly call "this.loadComplete()":
          >
          > var callback = {
          > /* ... */
          > success: function (oResponse) {
          > /* ... */
          > this.loadComplete();
          > },
          > scope: node
          > };
          >
          > [1] http://developer.yahoo.com/yui/connection/#scope
          >
          > Regards,
          >
          > --
          > Fiouz
          >
        • John
          Thanks again Fiouz, I figured it out. I had to do a tree.removeChildren(node); first then it worked great. ... changing ... I ... / ; ... + ... info , ... not
          Message 4 of 4 , Apr 2, 2008
          • 0 Attachment
            Thanks again Fiouz, I figured it out. I had to do a
            tree.removeChildren(node); first then it worked great.

            --- In ydn-javascript@yahoogroups.com, "John" <brjelder@...> wrote:
            >
            > Thanks for the reply.
            >
            > I added the scope and called this.loadComplete(), however that acts
            > exactly like node.loadComplete(). What this does is instead of
            changing
            > the existing node, it appends the new version right below the version
            I
            > want to replace.
            >
            > What I need it to do is to replace the old node.
            >
            > This is what my new code looks like:
            >
            > function updateNodeData(nodeLabel, edit) {
            > var node = getNodeByLabel(nodeLabel);
            > var editMod = ((edit == "true") ? "&editMod=true" : "");
            > if(node) {
            > var nodeLabel = encodeURI(node.label);
            > var patientId = <ww:property value="model.id" escape="false"
            />;
            > var sUrl = "NPSModuleAjaxResponse.action?query=" + nodeLabel
            +
            > "&pat=" + patientId + editMod;
            > var callback = {
            > success: function(oResponse) {
            > YAHOO.log("XHR transaction was successful.", "info",
            > "example");
            > var oResults = eval(oResponse.responseText);
            > if(YAHOO.lang.isArray(oResults)) {
            > for (var i=0, j=oResults.length; i<j; i++) {
            > var tempNode = new
            > YAHOO.widget.TextNode(oResults[i], node, false);
            > }
            > } else {
            > var tempNode = new
            > YAHOO.widget.HTMLNode(oResults.toString(), node, false, false);
            > }
            > this.loadComplete();
            > },
            > failure: function(oResponse) {
            > YAHOO.log("Failed to process XHR transaction.",
            "info",
            > "example");
            > oResponse.argument.fnLoadComplete();
            > },
            > argument: {
            > "node": node,
            > "fnLoadComplete": node.loadComplete
            > },
            > scope: node,
            > timeout: 7000
            > };
            > YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
            > }
            > else {
            > alert("Not working!");
            > }
            > }
            >
            > I also realized that node.getChildrenEl().innerHTML = oResults; did
            not
            > work at all. I replaced it with:
            > if(YAHOO.lang.isArray(oResults)) {
            > for (var i=0, j=oResults.length; i<j; i++) {
            > var tempNode = new
            > YAHOO.widget.TextNode(oResults[i], node, false);
            > }
            > } else {
            > var tempNode = new
            > YAHOO.widget.HTMLNode(oResults.toString(), node, false, false);
            > }
            >
            > Any thoughts?
            >
            > --- In ydn-javascript@yahoogroups.com, Fiouz fiouzy@ wrote:
            > >
            > > Hi,
            > >
            > > On Wed, Apr 2, 2008 at 6:14 PM, John brjelder@ wrote:
            > > > argument: {
            > > > "node": node,
            > > > "fnLoadComplete": node.loadComplete
            > > > },
            > >
            > > You must give the function as a closure because the "node" scope
            isn't
            > > held by the actual loadComplete function:
            > >
            > > "fnLoadComplete": function () { node.loadComplete(); }
            > >
            > > Another way is to define the "scope" attribute [1] so that "this"
            > > refers to "node" in order to directly call "this.loadComplete()":
            > >
            > > var callback = {
            > > /* ... */
            > > success: function (oResponse) {
            > > /* ... */
            > > this.loadComplete();
            > > },
            > > scope: node
            > > };
            > >
            > > [1] http://developer.yahoo.com/yui/connection/#scope
            > >
            > > Regards,
            > >
            > > --
            > > Fiouz
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.